Skip to content

Commit b9832f7

Browse files
avargitster
authored andcommitted
Makefile: add "po-init" rule to initialize po/XX.po
The core translation is the minimum set of work that must be done for a new language translation. There are over 5000 messages in the template message file "po/git.pot" that need to be translated. It is not a piece of cake for such a huge workload. So we used to define a small set of messages called "core translation" that a new l10n contributor must complete before sending pull request to the l10n coordinator. By pulling in some parts of the git-po-helper[^1] logic, we add a new rule to create this core translation message "po/git-core.pot": make po/git-core.pot To help new l10n contributors to initialized their "po/XX.pot" from "po/git-core.pot", we also add new rules "po-init": make po-init PO_FILE=po/XX.po [^1]: https://github.com/git-l10n/git-po-helper/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fbb3d32 commit b9832f7

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

Makefile

+39-1
Original file line numberDiff line numberDiff line change
@@ -2806,13 +2806,51 @@ po-update: po/git.pot
28062806
$(check_po_file_envvar)
28072807
@if test ! -e $(PO_FILE); then \
28082808
echo >&2 "error: $(PO_FILE) does not exist"; \
2809+
echo >&2 'To create an initial po file, use: "make po-init PO_FILE=po/XX.po"'; \
28092810
exit 1; \
28102811
fi
28112812
$(QUIET_MSGMERGE)$(MSGMERGE) $(MSGMERGE_FLAGS) $(PO_FILE) po/git.pot
28122813

28132814
.PHONY: check-pot
28142815
check-pot: $(LOCALIZED_ALL_GEN_PO)
28152816

2817+
### TODO FIXME: Translating everything in these files is a bad
2818+
### heuristic for "core", as we'll translate obscure error() messages
2819+
### along with commonly seen i18n messages. A better heuristic would
2820+
### be to e.g. use spatch to first remove error/die/warning
2821+
### etc. messages.
2822+
LOCALIZED_C_CORE =
2823+
LOCALIZED_C_CORE += builtin/checkout.c
2824+
LOCALIZED_C_CORE += builtin/clone.c
2825+
LOCALIZED_C_CORE += builtin/index-pack.c
2826+
LOCALIZED_C_CORE += builtin/push.c
2827+
LOCALIZED_C_CORE += builtin/reset.c
2828+
LOCALIZED_C_CORE += remote.c
2829+
LOCALIZED_C_CORE += wt-status.c
2830+
2831+
LOCALIZED_C_CORE_GEN_PO = $(LOCALIZED_C_CORE:%=.build/pot/po/%.po)
2832+
2833+
.build/pot/git-core.header: $(LOCALIZED_C_CORE_GEN_PO)
2834+
$(call mkdir_p_parent_template)
2835+
$(QUIET_GEN)$(gen_pot_header)
2836+
2837+
po/git-core.pot: .build/pot/git-core.header $(LOCALIZED_C_CORE_GEN_PO)
2838+
$(QUIET_GEN)$(MSGCAT) $^ >$@
2839+
2840+
.PHONY: po-init
2841+
po-init: po/git-core.pot
2842+
$(check_po_file_envvar)
2843+
@if test -e $(PO_FILE); then \
2844+
echo >&2 "error: $(PO_FILE) exists already"; \
2845+
exit 1; \
2846+
fi
2847+
$(QUIET_MSGINIT)msginit \
2848+
--input=$< \
2849+
--output=$(PO_FILE) \
2850+
--no-translator \
2851+
--locale=$(PO_FILE:po/%.po=%)
2852+
2853+
## po/*.po files & their rules
28162854
ifdef NO_GETTEXT
28172855
POFILES :=
28182856
MOFILES :=
@@ -3348,7 +3386,7 @@ cocciclean:
33483386

33493387
clean: profile-clean coverage-clean cocciclean
33503388
$(RM) -r .build
3351-
$(RM) po/git.pot
3389+
$(RM) po/git.pot po/git-core.pot
33523390
$(RM) *.res
33533391
$(RM) $(OBJECTS)
33543392
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)

po/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/build
22
/git.pot
3+
/git-core.pot

shared.mak

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ifndef V
6262
QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
6363
QUIET_LNCP = @echo ' ' LN/CP $@;
6464
QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
65+
QUIET_MSGINIT = @echo ' ' MSGINIT $@;
6566
QUIET_MSGFMT = @echo ' ' MSGFMT $@;
6667
QUIET_MSGMERGE = @echo ' ' MSGMERGE $@;
6768
QUIET_GCOV = @echo ' ' GCOV $@;

0 commit comments

Comments
 (0)