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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 26, 2022 at 22:50 UTC b9832f7e3bd615025d5703c635ab2179fcaed2a7
3 files changed +41 -1
Makefile
+39 -1
@@ -2806,6 +2806,7 @@ po-update: po/git.pot
2806 $(check_po_file_envvar)
2807 @if test ! -e $(PO_FILE); then \
2808 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"'; \
2810 exit 1; \
2811 fi
2812 $(QUIET_MSGMERGE)$(MSGMERGE) $(MSGMERGE_FLAGS) $(PO_FILE) po/git.pot
@@ -2813,6 +2814,43 @@ po-update: po/git.pot
2814 .PHONY: check-pot
2815 check-pot: $(LOCALIZED_ALL_GEN_PO)
2816
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
2854 ifdef NO_GETTEXT
2855 POFILES :=
2856 MOFILES :=
@@ -3348,7 +3386,7 @@ cocciclean:
3386
3387 clean: profile-clean coverage-clean cocciclean
3388 $(RM) -r .build
3351 - $(RM) po/git.pot
3389 + $(RM) po/git.pot po/git-core.pot
3390 $(RM) *.res
3391 $(RM) $(OBJECTS)
3392 $(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
po/.gitignore
+1
@@ -1,2 +1,3 @@
1 /build
2 /git.pot
3 +/git-core.pot
shared.mak
+1
@@ -62,6 +62,7 @@ ifndef V
62 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
63 QUIET_LNCP = @echo ' ' LN/CP $@;
64 QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
65 + QUIET_MSGINIT = @echo ' ' MSGINIT $@;
66 QUIET_MSGFMT = @echo ' ' MSGFMT $@;
67 QUIET_MSGMERGE = @echo ' ' MSGMERGE $@;
68 QUIET_GCOV = @echo ' ' GCOV $@;