git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Makefile: generate pot file using a tweaked version of xgettext

From
Jiang Xin <worldhello.net@gmail.com>
Date
Jul 22, 2017, 00:52 UTC
Message-ID
<a87e7252bf9de8a87e5dc7712946f72459778d6c.1500684532.git.worldhello.net@gmail.com>
In-Reply-To
<CANYiYbGkuGNNYn4OF5w=1+Pqn9hEHWcD+DYVB6AXRs0vFEsY2Q@mail.gmail.com>

Instead of doing a sed (s|PRItime|PRIuMAX) in working tree directly, we can use a tweaked version of gettext, which can replace PRItime macro to PRIuMAX (version 1.x) in runtime. We do not need to reset our working tree anymore, and this operation can be run without a version controlled working tree.

The tweaked version of gettext is hosted at:
    https://github.com/jiangxin/gettext
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
---
 Makefile | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index 461c845d33..782c519133 100644
--- a/Makefile
+++ b/Makefile
@@ -2221,33 +2221,23 @@ 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.
 ## 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.
+## we use a hacked version of xgettext to replace PRItime with PRIuMAX.
+## We need to update this to PRIdMAX if we switch to a signed type later.
 
-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
-
-	@for s in $(LOCALIZED_C) $(LOCALIZED_SH) $(LOCALIZED_PERL); \
-	do \
-		sed -e 's|PRItime|PRIuMAX|g' <"$$s" >"$$s+" && \
-		cat "$$s+" >"$$s" && rm "$$s+"; \
-	done
+check-xgettext:
+	@if ! $(XGETTEXT) --version | grep -q "PRItime tweak v1"; then \
+		echo >&2 "Error: must use a hacked version of xgettext, which can convert PRItime macro as we need."; \
+		echo >&2 "Error: download it from https://github.com/jiangxin/gettext"; \
+		exit 1; \
+	fi
 
+po/git.pot: check-xgettext $(GENERATED_H) FORCE
 	$(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)
-
-	# Reverting the munged source, leaving only the updated $@
-	git reset --hard
 	mv $@+ $@
 
 .PHONY: pot
@@ -2737,6 +2727,7 @@ check-builtins::
 .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
 .PHONY: coverage-untested-functions cover_db cover_db_html
 .PHONY: coverage-clean-results
+.PHONY: check-xgettext
 
 coverage:
 	$(MAKE) coverage-test
-- 
2.14.0.rc0.1.g3ccfa2fb49
Previous: Jiang XinNext: Junio C Hamano
Message 28 of 45 in “[L10N] Kickoff of translation for Git 2.14.0 round 1”
  1. Jiang XinJul 15, 2017
  2. Jean-Noël AvilaJul 15, 2017
  3. Jiang XinJul 17, 2017
  4. Johannes SchindelinJul 17, 2017
  5. Jiang XinJul 18, 2017
  6. PRItime: wrap PRItime for better l10n compatibilityJiang Xin, Jul 17, 2017
  7. Junio C HamanoJul 17, 2017
  8. Jiang XinJul 18, 2017
  9. Junio C HamanoJul 18, 2017
  10. Jiang XinJul 19, 2017
  11. Johannes SchindelinJul 19, 2017
  12. Junio C HamanoJul 19, 2017
  13. Junio C HamanoJul 19, 2017
  14. Junio C HamanoJul 20, 2017
  15. Junio C HamanoJul 20, 2017
  16. Junio C HamanoJul 20, 2017
  17. Jean-Noël AvilaJul 21, 2017
  18. Junio C HamanoJul 21, 2017
  19. Johannes SchindelinJul 22, 2017
  20. Junio C HamanoJul 22, 2017
  21. Johannes SchindelinJul 25, 2017
  22. Junio C HamanoJul 25, 2017
  23. Jiang XinJul 21, 2017
  24. Junio C HamanoJul 21, 2017
  25. Jiang XinJul 21, 2017
  26. Junio C HamanoJul 21, 2017
  27. Jiang XinJul 22, 2017
  28. Makefile: generate pot file using a tweaked version of xgettextJiang Xin, Jul 22, 2017
  29. Junio C HamanoJul 22, 2017
  30. Johannes SchindelinJul 22, 2017
  31. Junio C HamanoJul 22, 2017
  32. Jiang XinJul 24, 2017
  33. Johannes SchindelinJul 25, 2017
  34. Junio C HamanoJul 25, 2017
  35. Jiang XinJul 24, 2017
  36. Junio C HamanoJul 24, 2017
  37. Johannes SchindelinJul 25, 2017
  38. Jean-Noël AVILAJul 23, 2017
  39. Junio C HamanoJul 23, 2017
  40. Jiang XinJul 24, 2017
  41. Junio C HamanoJul 24, 2017
  42. Kaartic SivaraamJul 22, 2017
  43. Jean-Noël AvilaJul 23, 2017
  44. Jordi MasJul 19, 2017
  45. Jiang XinJul 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.