Makefile: add "po-update" rule to update po/XX.po
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>
Jiang Xin committed
May 26, 2022 at 22:50 UTC
fbb3d323936d856e1091b137481e5edb15162619
2 files changed
+19
Makefile
+18
@@ -571,6 +571,7 @@ TCLTK_PATH = wish
571
XGETTEXT = xgettext
572
MSGCAT = msgcat
573
MSGFMT = msgfmt
574
+MSGMERGE = msgmerge
575
CURL_CONFIG = curl-config
576
GCOV = gcov
577
STRIP = strip
@@ -2715,6 +2716,7 @@ XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
2716
--keyword=gettextln --keyword=eval_gettextln
2717
XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
2718
--keyword=__ --keyword=N__ --keyword="__n:1,2"
2719
+MSGMERGE_FLAGS = --add-location --backup=off --update
2720
LOCALIZED_C = $(sort $(FOUND_C_SOURCES) $(FOUND_H_SOURCES) $(SCALAR_SOURCES) \
2721
$(GENERATED_H))
2722
LOCALIZED_SH = $(sort $(SCRIPT_SH) git-sh-setup.sh)
@@ -2792,6 +2794,22 @@ po/git.pot: .build/pot/git.header $(LOCALIZED_ALL_GEN_PO)
2794
.PHONY: pot
2795
pot: po/git.pot
2796
2797
+define check_po_file_envvar
2798
+ $(if $(PO_FILE), \
2799
+ $(if $(filter po/%.po,$(PO_FILE)), , \
2800
+ $(error PO_FILE should match pattern: "po/%.po")), \
2801
+ $(error PO_FILE is not defined))
2802
+endef
2803
+
2804
+.PHONY: po-update
2805
+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
+ exit 1; \
2810
+ fi
2811
+ $(QUIET_MSGMERGE)$(MSGMERGE) $(MSGMERGE_FLAGS) $(PO_FILE) po/git.pot
2812
+
2813
.PHONY: check-pot
2814
check-pot: $(LOCALIZED_ALL_GEN_PO)
2815
shared.mak
+1
@@ -63,6 +63,7 @@ ifndef V
63
QUIET_LNCP = @echo ' ' LN/CP $@;
64
QUIET_XGETTEXT = @echo ' ' XGETTEXT $@;
65
QUIET_MSGFMT = @echo ' ' MSGFMT $@;
66
+ QUIET_MSGMERGE = @echo ' ' MSGMERGE $@;
67
QUIET_GCOV = @echo ' ' GCOV $@;
68
QUIET_SP = @echo ' ' SP $<;
69
QUIET_HDR = @echo ' ' HDR $(<:hcc=h);