Message ID | 20220523152128.26380-4-worldhello.net@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Incremental po/git.pot update and new l10n workflow | expand |
Jiang Xin <worldhello.net@gmail.com> writes: > ## Gettext tools cannot work with our own custom PRItime type, so > ## we replace PRItime with PRIuMAX. We need to update this to > ## PRIdMAX if we switch to a signed type later. > +$(LOCALIZED_C_GEN_PO): .build/pot/po/%.po: % > + $(call mkdir_p_parent_template) > + $(QUIET_XGETTEXT) \ > + if grep -q PRItime $<; then \ > + (\ > + sed -e 's|PRItime|PRIuMAX|g' <$< \ > + >.build/pot/po/$< && \ > + cd .build/pot/po && \ > + $(XGETTEXT) --omit-header \ > + -o $(@:.build/pot/po/%=%) \ > + $(XGETTEXT_FLAGS_C) $< && \ > + rm $<; \ > + ); \ > + else \ > + $(XGETTEXT) --omit-header \ > + -o $@ $(XGETTEXT_FLAGS_C) $<; \ > + fi My build (a random hack on top of 'seen') is getting this message $ make Makefile:2755: target '.build/pot/po/archive.c.po' given more than once in the same rule Makefile:2755: target '.build/pot/po/archive.c.po' given more than once in the same rule SUBDIR git-gui I haven't changed archive.c in particular relative to 'seen', and .build/pot/po directory seems to be empty (understandably---I have not run the po/ stuff myself lately).
Junio C Hamano <gitster@pobox.com> writes: > Jiang Xin <worldhello.net@gmail.com> writes: > >> ## Gettext tools cannot work with our own custom PRItime type, so >> ## we replace PRItime with PRIuMAX. We need to update this to >> ## PRIdMAX if we switch to a signed type later. >> +$(LOCALIZED_C_GEN_PO): .build/pot/po/%.po: % >> + $(call mkdir_p_parent_template) >> + $(QUIET_XGETTEXT) \ >> + if grep -q PRItime $<; then \ >> + (\ >> + sed -e 's|PRItime|PRIuMAX|g' <$< \ >> + >.build/pot/po/$< && \ >> + cd .build/pot/po && \ >> + $(XGETTEXT) --omit-header \ >> + -o $(@:.build/pot/po/%=%) \ >> + $(XGETTEXT_FLAGS_C) $< && \ >> + rm $<; \ >> + ); \ >> + else \ >> + $(XGETTEXT) --omit-header \ >> + -o $@ $(XGETTEXT_FLAGS_C) $<; \ >> + fi > > My build (a random hack on top of 'seen') is getting this message > > $ make > Makefile:2755: target '.build/pot/po/archive.c.po' given more than once in the same rule > Makefile:2755: target '.build/pot/po/archive.c.po' given more than once in the same rule > SUBDIR git-gui > > I haven't changed archive.c in particular relative to 'seen', and > .build/pot/po directory seems to be empty (understandably---I have > not run the po/ stuff myself lately). Well, I lied. I am doing the random hack while in a conflicted state coming from an interrupted merge that had conflicts in the archive.c. Perhaps we need some logic to dedup "ls-files" output?
On Thu, May 26, 2022 at 6:24 AM Junio C Hamano <gitster@pobox.com> wrote: > > Junio C Hamano <gitster@pobox.com> writes: > > > Jiang Xin <worldhello.net@gmail.com> writes: > > > >> ## Gettext tools cannot work with our own custom PRItime type, so > >> ## we replace PRItime with PRIuMAX. We need to update this to > >> ## PRIdMAX if we switch to a signed type later. > >> +$(LOCALIZED_C_GEN_PO): .build/pot/po/%.po: % > >> + $(call mkdir_p_parent_template) > >> + $(QUIET_XGETTEXT) \ > >> + if grep -q PRItime $<; then \ > >> + (\ > >> + sed -e 's|PRItime|PRIuMAX|g' <$< \ > >> + >.build/pot/po/$< && \ > >> + cd .build/pot/po && \ > >> + $(XGETTEXT) --omit-header \ > >> + -o $(@:.build/pot/po/%=%) \ > >> + $(XGETTEXT_FLAGS_C) $< && \ > >> + rm $<; \ > >> + ); \ > >> + else \ > >> + $(XGETTEXT) --omit-header \ > >> + -o $@ $(XGETTEXT_FLAGS_C) $<; \ > >> + fi > > > > My build (a random hack on top of 'seen') is getting this message > > > > $ make > > Makefile:2755: target '.build/pot/po/archive.c.po' given more than once in the same rule > > Makefile:2755: target '.build/pot/po/archive.c.po' given more than once in the same rule > > SUBDIR git-gui > > > > I haven't changed archive.c in particular relative to 'seen', and > > .build/pot/po directory seems to be empty (understandably---I have > > not run the po/ stuff myself lately). > > Well, I lied. I am doing the random hack while in a conflicted > state coming from an interrupted merge that had conflicts in the > archive.c. > > Perhaps we need some logic to dedup "ls-files" output? Yes, we can pass the option "--deduplicate" to git-ls-files to suppress duplicate entries for unresolved conflicts. Will send an additional patch for this.
diff --git a/.gitignore b/.gitignore index e81de1063a..a452215764 100644 --- a/.gitignore +++ b/.gitignore @@ -200,6 +200,7 @@ *.[aos] *.o.json *.py[co] +.build/ .depend/ *.gcda *.gcno diff --git a/Makefile b/Makefile index 46914dcd80..1962999c18 100644 --- a/Makefile +++ b/Makefile @@ -569,6 +569,7 @@ INSTALL = install TCL_PATH = tclsh TCLTK_PATH = wish XGETTEXT = xgettext +MSGCAT = msgcat MSGFMT = msgfmt CURL_CONFIG = curl-config GCOV = gcov @@ -2706,6 +2707,7 @@ XGETTEXT_FLAGS = \ --force-po \ --add-comments=TRANSLATORS: \ --msgid-bugs-address="Git Mailing List <git@vger.kernel.org>" \ + --package-name=Git \ --sort-by-file \ --from-code=UTF-8 XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \ @@ -2714,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" +MSGCAT_FLAGS = --sort-by-file LOCALIZED_C = $(FOUND_C_SOURCES) $(FOUND_H_SOURCES) $(SCALAR_SOURCES) \ $(GENERATED_H) LOCALIZED_SH = $(SCRIPT_SH) @@ -2726,34 +2729,68 @@ LOCALIZED_SH += t/t0200/test.sh LOCALIZED_PERL += t/t0200/test.perl endif -## Note that this is meant to be run only by the localization coordinator -## under a very controlled condition, i.e. (1) it is to be run in a -## Git repository (not a tarball extract), (2) any local modifications -## will be lost. +## We generate intermediate .build/pot/po/%.po files containing a +## extract of the translations we find in each file in the source +## tree. We will assemble them using msgcat to create the final +## "po/git.pot" file. +LOCALIZED_ALL_GEN_PO = + +LOCALIZED_C_GEN_PO = $(LOCALIZED_C:%=.build/pot/po/%.po) +LOCALIZED_ALL_GEN_PO += $(LOCALIZED_C_GEN_PO) + +LOCALIZED_SH_GEN_PO = $(LOCALIZED_SH:%=.build/pot/po/%.po) +LOCALIZED_ALL_GEN_PO += $(LOCALIZED_SH_GEN_PO) + +LOCALIZED_PERL_GEN_PO = $(LOCALIZED_PERL:%=.build/pot/po/%.po) +LOCALIZED_ALL_GEN_PO += $(LOCALIZED_PERL_GEN_PO) + ## Gettext tools cannot work with our own custom PRItime type, so ## we replace PRItime with PRIuMAX. We need to update this to ## PRIdMAX if we switch to a signed type later. +$(LOCALIZED_C_GEN_PO): .build/pot/po/%.po: % + $(call mkdir_p_parent_template) + $(QUIET_XGETTEXT) \ + if grep -q PRItime $<; then \ + (\ + sed -e 's|PRItime|PRIuMAX|g' <$< \ + >.build/pot/po/$< && \ + cd .build/pot/po && \ + $(XGETTEXT) --omit-header \ + -o $(@:.build/pot/po/%=%) \ + $(XGETTEXT_FLAGS_C) $< && \ + rm $<; \ + ); \ + else \ + $(XGETTEXT) --omit-header \ + -o $@ $(XGETTEXT_FLAGS_C) $<; \ + fi -po/git.pot: $(GENERATED_H) FORCE - # All modifications will be reverted at the end, so we do not - # want to have any local change. - git diff --quiet HEAD && git diff --quiet --cached +$(LOCALIZED_SH_GEN_PO): .build/pot/po/%.po: % + $(call mkdir_p_parent_template) + $(QUIET_XGETTEXT)$(XGETTEXT) --omit-header \ + -o$@ $(XGETTEXT_FLAGS_SH) $< - @for s in $(LOCALIZED_C) $(LOCALIZED_SH) $(LOCALIZED_PERL); \ - do \ - sed -e 's|PRItime|PRIuMAX|g' <"$$s" >"$$s+" && \ - cat "$$s+" >"$$s" && rm "$$s+"; \ - done +$(LOCALIZED_PERL_GEN_PO): .build/pot/po/%.po: % + $(call mkdir_p_parent_template) + $(QUIET_XGETTEXT)$(XGETTEXT) --omit-header \ + -o$@ $(XGETTEXT_FLAGS_PERL) $< + +define gen_pot_header +$(XGETTEXT) $(XGETTEXT_FLAGS_C) \ + -o - /dev/null | \ +sed -e 's|charset=CHARSET|charset=UTF-8|' \ + -e 's|\(Last-Translator: \)FULL NAME <.*>|\1make by the Makefile|' \ + -e 's|\(Language-Team: \)LANGUAGE <.*>|\1Git Mailing List <git@vger.kernel.org>|' \ + >$@ && \ +echo '"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"' >>$@ +endef - $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C) - $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \ - $(LOCALIZED_SH) - $(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_PERL) \ - $(LOCALIZED_PERL) +.build/pot/git.header: $(LOCALIZED_ALL_GEN_PO) + $(call mkdir_p_parent_template) + $(QUIET_GEN)$(gen_pot_header) - # Reverting the munged source, leaving only the updated $@ - git reset --hard - mv $@+ $@ +po/git.pot: .build/pot/git.header $(LOCALIZED_ALL_GEN_PO) FORCE + $(QUIET_GEN)$(MSGCAT) $(MSGCAT_FLAGS) $(filter-out FORCE,$^) >$@ .PHONY: pot pot: po/git.pot @@ -3292,6 +3329,7 @@ cocciclean: $(RM) contrib/coccinelle/*.cocci.patch* clean: profile-clean coverage-clean cocciclean + $(RM) -r .build $(RM) *.res $(RM) $(OBJECTS) $(RM) $(LIB_FILE) $(XDIFF_LIB) $(REFTABLE_LIB) $(REFTABLE_TEST_LIB)