@@ -2799,6 +2799,7 @@ endif
endif
@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
@@ -2806,6 +2807,55 @@ endif
.PHONY: check-pot
check-pot: pot
+### 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)
+
+.PHONY: core-pot
+core-pot: po/git-core.pot
+
+.build/pot/git-core.header: $(LOCALIZED_C_CORE_GEN_PO)
+ $(call mkdir_p_parent_template)
+ $(QUIET_XGETTEXT)$(XGETTEXT) $(XGETTEXT_FLAGS_C) \
+ -o - /dev/null | \
+ sed -e 's|charset=CHARSET|charset=UTF-8|g' >$@ && \
+ echo '"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"' >>$@
+
+po/git-core.pot: .build/pot/git-core.header $(LOCALIZED_C_CORE_GEN_PO)
+ $(QUIET_GEN)$(MSGCAT) $(MSGCAT_FLAGS) $^ >$@
+
+.PHONY: po-init
+po-init: po/git-core.pot
+ifndef PO_FILE
+ $(error not define variable "PO_FILE")
+else
+ifeq ($(filter po/%.po,$(PO_FILE)),)
+ $(error PO_FILE should match pattern: "po/%.po")
+endif
+endif
+ @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 :=
@@ -1,2 +1,3 @@
/build
/git.pot
+/git-core.pot
@@ -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 $@;