]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Makefile: add "po-init" rule to initialize po/XX.po
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 26 May 2022 14:50:34 +0000 (22:50 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 17:32:57 +0000 (10:32 -0700)
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>
Makefile
po/.gitignore
shared.mak

index efd242b255b0e54c97b171bca8d17c281333d530..0a5b4b4edefc6be543287ea9dde2b7ec613f1785 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2806,6 +2806,7 @@ po-update: po/git.pot
        $(check_po_file_envvar)
        @if test ! -e $(PO_FILE); then \
                echo >&2 "error: $(PO_FILE) does not exist"; \
+               echo >&2 'To create an initial po file, use: "make po-init PO_FILE=po/XX.po"'; \
                exit 1; \
        fi
        $(QUIET_MSGMERGE)$(MSGMERGE) $(MSGMERGE_FLAGS) $(PO_FILE) po/git.pot
@@ -2813,6 +2814,43 @@ po-update: po/git.pot
 .PHONY: check-pot
 check-pot: $(LOCALIZED_ALL_GEN_PO)
 
+### TODO FIXME: Translating everything in these files is a bad
+### heuristic for "core", as we'll translate obscure error() messages
+### along with commonly seen i18n messages. A better heuristic would
+### be to e.g. use spatch to first remove error/die/warning
+### etc. messages.
+LOCALIZED_C_CORE =
+LOCALIZED_C_CORE += builtin/checkout.c
+LOCALIZED_C_CORE += builtin/clone.c
+LOCALIZED_C_CORE += builtin/index-pack.c
+LOCALIZED_C_CORE += builtin/push.c
+LOCALIZED_C_CORE += builtin/reset.c
+LOCALIZED_C_CORE += remote.c
+LOCALIZED_C_CORE += wt-status.c
+
+LOCALIZED_C_CORE_GEN_PO = $(LOCALIZED_C_CORE:%=.build/pot/po/%.po)
+
+.build/pot/git-core.header: $(LOCALIZED_C_CORE_GEN_PO)
+       $(call mkdir_p_parent_template)
+       $(QUIET_GEN)$(gen_pot_header)
+
+po/git-core.pot: .build/pot/git-core.header $(LOCALIZED_C_CORE_GEN_PO)
+       $(QUIET_GEN)$(MSGCAT) $^ >$@
+
+.PHONY: po-init
+po-init: po/git-core.pot
+       $(check_po_file_envvar)
+       @if test -e $(PO_FILE); then \
+               echo >&2 "error: $(PO_FILE) exists already"; \
+               exit 1; \
+       fi
+       $(QUIET_MSGINIT)msginit \
+               --input=$< \
+               --output=$(PO_FILE) \
+               --no-translator \
+               --locale=$(PO_FILE:po/%.po=%)
+
+## po/*.po files & their rules
 ifdef NO_GETTEXT
 POFILES :=
 MOFILES :=
@@ -3348,7 +3386,7 @@ cocciclean:
 
 clean: profile-clean coverage-clean cocciclean
        $(RM) -r .build
-       $(RM) po/git.pot
+       $(RM) po/git.pot po/git-core.pot
        $(RM) *.res
        $(RM) $(OBJECTS)
        $(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)
index 37d1301b32ea9692b8cc8cee1c4076d861ba43a3..ff0e5176a65dbd4d82ec9d5bf282afabf1704ea2 100644 (file)
@@ -1,2 +1,3 @@
 /build
 /git.pot
+/git-core.pot
index 8cd170a7e739a9763831b17ecce6e7da18549b60..4330192e9c363df8103e27d5ccb06769adfbc0b8 100644 (file)
@@ -62,6 +62,7 @@ ifndef V
        QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
        QUIET_LNCP     = @echo '   ' LN/CP $@;
        QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
+       QUIET_MSGINIT  = @echo '   ' MSGINIT $@;
        QUIET_MSGFMT   = @echo '   ' MSGFMT $@;
        QUIET_MSGMERGE = @echo '   ' MSGMERGE $@;
        QUIET_GCOV     = @echo '   ' GCOV $@;