]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Makefile: add "po-update" rule to update po/XX.po
authorJiang Xin <zhiyou.jx@alibaba-inc.com>
Thu, 26 May 2022 14:50:33 +0000 (22:50 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 17:32:55 +0000 (10:32 -0700)
Since there is no longer a "po/git.pot" file in tree, a l10n team leader
has to run several commands to update their "po/XX.po" file:

    $ make pot
    $ msgmerge --add-location --backup=off -U po/XX.po po/git.pot

To make this process easier, add a new rule so that l10n team leaders
can update their "po/XX.po" with one command. E.g.:

    $ make po-update PO_FILE=po/zh_CN.po

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
shared.mak

index cc3eb856b2243df32d70fe5d5baede6a903176ba..efd242b255b0e54c97b171bca8d17c281333d530 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -571,6 +571,7 @@ TCLTK_PATH = wish
 XGETTEXT = xgettext
 MSGCAT = msgcat
 MSGFMT = msgfmt
+MSGMERGE = msgmerge
 CURL_CONFIG = curl-config
 GCOV = gcov
 STRIP = strip
@@ -2715,6 +2716,7 @@ XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
        --keyword=gettextln --keyword=eval_gettextln
 XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
        --keyword=__ --keyword=N__ --keyword="__n:1,2"
+MSGMERGE_FLAGS = --add-location --backup=off --update
 LOCALIZED_C = $(sort $(FOUND_C_SOURCES) $(FOUND_H_SOURCES) $(SCALAR_SOURCES) \
                $(GENERATED_H))
 LOCALIZED_SH = $(sort $(SCRIPT_SH) git-sh-setup.sh)
@@ -2792,6 +2794,22 @@ po/git.pot: .build/pot/git.header $(LOCALIZED_ALL_GEN_PO)
 .PHONY: pot
 pot: po/git.pot
 
+define check_po_file_envvar
+       $(if $(PO_FILE), \
+               $(if $(filter po/%.po,$(PO_FILE)), , \
+                       $(error PO_FILE should match pattern: "po/%.po")), \
+               $(error PO_FILE is not defined))
+endef
+
+.PHONY: po-update
+po-update: po/git.pot
+       $(check_po_file_envvar)
+       @if test ! -e $(PO_FILE); then \
+               echo >&2 "error: $(PO_FILE) does not exist"; \
+               exit 1; \
+       fi
+       $(QUIET_MSGMERGE)$(MSGMERGE) $(MSGMERGE_FLAGS) $(PO_FILE) po/git.pot
+
 .PHONY: check-pot
 check-pot: $(LOCALIZED_ALL_GEN_PO)
 
index 50d4596f0d6084b8537c31a89fb2932565aa800a..8cd170a7e739a9763831b17ecce6e7da18549b60 100644 (file)
@@ -63,6 +63,7 @@ ifndef V
        QUIET_LNCP     = @echo '   ' LN/CP $@;
        QUIET_XGETTEXT = @echo '   ' XGETTEXT $@;
        QUIET_MSGFMT   = @echo '   ' MSGFMT $@;
+       QUIET_MSGMERGE = @echo '   ' MSGMERGE $@;
        QUIET_GCOV     = @echo '   ' GCOV $@;
        QUIET_SP       = @echo '   ' SP $<;
        QUIET_HDR      = @echo '   ' HDR $(<:hcc=h);