{"thread":{"id":"31337","subject":"[PATCH 0/6] Gettext poison rework","startedAt":"2012-08-24T05:43:00Z","lastAt":"2012-08-24T16:02:04Z","messageCount":10,"participants":["Nguyễn Thái Ngọc Duy","Ævar Arnfjörð Bjarmason","Nguyen Thai Ngoc Duy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"197745","messageId":"1345786986-10826-1-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":null,"subject":"[PATCH 0/6] Gettext poison rework","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:00Z","receivedAt":"2012-08-24T05:43:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Still WIP but I'm getting closer. I dropped test-poisongen and started\nto use podebug [2] instead. Less code in git. podebug does not preserve\nshell variables yet. I'll follow that up at upstream [1].\n\nWith this series, if you have translation toolkit installed, you could\ndo\n\n    make pseudo-locale L=<your language code>\n    make GETTEXT_POISON=$LANG test\n\npodebug supports a few way of rewriting translations. Currently\n\"unicode\" is used but you can change it via PODEBUG_OPTS\n\nt9001 is not happy with $LANG != C though. May need to add some\nprereq there.\n\n[1] http://bugs.locamotion.org/show_bug.cgi?id=2450\n[2] http://translate.sourceforge.net/wiki/toolkit/podebug\n\nNguyễn Thái Ngọc Duy (6):\n  Makefile: do not mark strings for l10n from test programs\n  Makefile: recreate git.pot if *.sh or *.perl changes\n  Replace gettext poison implementation with pseudotranslation\n    generation\n  Initialize gettext for test programs that may use it\n  Support logging unmarked strings\n  test-parse-options: mark parseopt help strings for pseudotranslation\n\n .gitignore                |  1 +\n Makefile                  | 48 +++++++++++++++++++++---------------\n gettext.c                 | 10 --------\n gettext.h                 | 10 +-------\n git-sh-i18n.sh            | 14 -----------\n po/.gitignore             |  1 +\n po/README                 | 15 +++++------\n t/.gitignore              |  1 +\n t/lib-gettext.sh          |  7 +++++-\n t/t0200-gettext-basic.sh  |  1 +\n t/t0205-gettext-poison.sh | 36 ---------------------------\n t/test-lib.sh             |  2 +-\n test-date.c               |  1 +\n test-delta.c              |  1 +\n test-dump-cache-tree.c    |  5 +++-\n test-index-version.c      |  1 +\n test-match-trees.c        |  1 +\n test-mergesort.c          |  1 +\n test-parse-options.c      | 63 ++++++++++++++++++++++++-----------------------\n test-path-utils.c         |  1 +\n test-revision-walking.c   |  1 +\n test-scrap-cache-tree.c   |  4 ++-\n test-sha1.c               |  1 +\n test-subprocess.c         |  1 +\n wrap-for-bin.sh           | 16 +++++++++++-\n 25 files changed, 111 insertions(+), 132 deletions(-)\n delete mode 100755 t/t0205-gettext-poison.sh\n\n-- \n1.7.12.rc2\n"},{"id":"197746","messageId":"1345786986-10826-2-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 1/6] Makefile: do not mark strings for l10n from test programs","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:01Z","receivedAt":"2012-08-24T05:43:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Makefile | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 6b0c961..ddeb04d 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2398,7 +2398,8 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \\\n \t--keyword=gettextln --keyword=eval_gettextln\n XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl\n-LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n+C_OBJ_NOTESTS:= $(filter-out test-%,$(C_OBJ))\n+LOCALIZED_C := $(C_OBJ_NOTESTS:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH := $(SCRIPT_SH)\n LOCALIZED_PERL := $(SCRIPT_PERL)\n \n-- \n1.7.12.rc2\n"},{"id":"197747","messageId":"1345786986-10826-3-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 2/6] Makefile: recreate git.pot if *.sh or *.perl changes","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:02Z","receivedAt":"2012-08-24T05:43:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex ddeb04d..485978f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2409,7 +2409,7 @@ LOCALIZED_SH += t/t0200/test.sh\n LOCALIZED_PERL += t/t0200/test.perl\n endif\n \n-po/git.pot: $(LOCALIZED_C)\n+po/git.pot: $(LOCALIZED_C) $(LOCALIZED_SH) $(LOCALIZED_PERL)\n \t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)\n \t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \\\n \t\t$(LOCALIZED_SH)\n-- \n1.7.12.rc2\n"},{"id":"197748","messageId":"1345786986-10826-4-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 3/6] Replace gettext poison implementation with pseudotranslation generation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:03Z","receivedAt":"2012-08-24T05:43:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Makefile                  | 45 ++++++++++++++++++++++++++-------------------\n gettext.c                 | 10 ----------\n gettext.h                 | 10 +---------\n git-sh-i18n.sh            | 14 --------------\n po/.gitignore             |  1 +\n po/README                 | 15 ++++++++-------\n t/.gitignore              |  1 +\n t/lib-gettext.sh          |  7 ++++++-\n t/t0200-gettext-basic.sh  |  1 +\n t/t0205-gettext-poison.sh | 36 ------------------------------------\n t/test-lib.sh             |  2 +-\n wrap-for-bin.sh           | 10 +++++++++-\n 12 files changed, 54 insertions(+), 98 deletions(-)\n delete mode 100755 t/t0205-gettext-poison.sh\n\ndiff --git a/Makefile b/Makefile\nindex 485978f..89f4fc0 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -258,11 +258,6 @@ all::\n # Define HAVE_DEV_TTY if your system can open /dev/tty to interact with the\n # user.\n #\n-# Define GETTEXT_POISON if you are debugging the choice of strings marked\n-# for translation.  In a GETTEXT_POISON build, you can turn all strings marked\n-# for translation into gibberish by setting the GIT_GETTEXT_POISON variable\n-# (to any value) in your environment.\n-#\n # Define JSMIN to point to JavaScript minifier that functions as\n # a filter to have gitweb.js minified.\n #\n@@ -376,6 +371,8 @@ MSGFMT = msgfmt\n PTHREAD_LIBS = -lpthread\n PTHREAD_CFLAGS =\n GCOV = gcov\n+PODEBUG = podebug\n+PODEBUG_OPTS = --rewrite=unicode\n \n export TCL_PATH TCLTK_PATH\n \n@@ -1594,9 +1591,6 @@ endif\n ifdef NO_SYMLINK_HEAD\n \tBASIC_CFLAGS += -DNO_SYMLINK_HEAD\n endif\n-ifdef GETTEXT_POISON\n-\tBASIC_CFLAGS += -DGETTEXT_POISON\n-endif\n ifdef NO_GETTEXT\n \tBASIC_CFLAGS += -DNO_GETTEXT\n \tUSE_GETTEXT_SCHEME ?= fallthrough\n@@ -2403,19 +2397,28 @@ LOCALIZED_C := $(C_OBJ_NOTESTS:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH := $(SCRIPT_SH)\n LOCALIZED_PERL := $(SCRIPT_PERL)\n \n-ifdef XGETTEXT_INCLUDE_TESTS\n-LOCALIZED_C += t/t0200/test.c\n-LOCALIZED_SH += t/t0200/test.sh\n-LOCALIZED_PERL += t/t0200/test.perl\n-endif\n+LOCALIZED_C_TESTS += t/t0200/test.c $(TEST_OBJS:o=c)\n+LOCALIZED_SH_TESTS += t/t0200/test.sh\n+LOCALIZED_PERL_TESTS += t/t0200/test.perl\n \n-po/git.pot: $(LOCALIZED_C) $(LOCALIZED_SH) $(LOCALIZED_PERL)\n-\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)\n-\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_SH) \\\n+po/git.pot+: $(LOCALIZED_C) $(LOCALIZED_SH) $(LOCALIZED_PERL)\n+\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@ $(XGETTEXT_FLAGS_C) $(LOCALIZED_C)\n+\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@ --join-existing $(XGETTEXT_FLAGS_SH) \\\n \t\t$(LOCALIZED_SH)\n-\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@+ --join-existing $(XGETTEXT_FLAGS_PERL) \\\n+\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@ --join-existing $(XGETTEXT_FLAGS_PERL) \\\n \t\t$(LOCALIZED_PERL)\n-\tmv $@+ $@\n+\n+po/git.pot: po/git.pot+\n+\tmv $< $@\n+\n+t/test.po: po/git.pot+ $(LOCALIZED_C_TESTS) $(LOCALIZED_SH_TESTS) $(LOCALIZED_PERL_TESTS)\n+\tcp $< $@t\n+\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@t --join-existing $(XGETTEXT_FLAGS_C) $(LOCALIZED_C_TESTS)\n+\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@t --join-existing $(XGETTEXT_FLAGS_SH) \\\n+\t\t$(LOCALIZED_SH_TESTS)\n+\t$(QUIET_XGETTEXT)$(XGETTEXT) -o$@t --join-existing $(XGETTEXT_FLAGS_PERL) \\\n+\t\t$(LOCALIZED_PERL_TESTS)\n+\t$(PODEBUG) $(PODEBUG_OPTS) $@t -o $@\n \n pot: po/git.pot\n \n@@ -2429,6 +2432,11 @@ endif\n po/build/locale/%/LC_MESSAGES/git.mo: po/%.po\n \t$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<\n \n+po/build/pseudo-locale/$(L)/LC_MESSAGES/git.mo: t/test.po\n+\t$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<\n+\n+pseudo-locale: po/build/pseudo-locale/$(L)/LC_MESSAGES/git.mo\n+\n FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \\\n \t\t\t$(FIND) . \\( -name .git -type d -prune \\) \\\n \t\t\t\t-o \\( -name '*.[hcS]' -type f -print \\) )\n@@ -2498,7 +2506,6 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT\n \t@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@\n endif\n \t@echo NO_GETTEXT=\\''$(subst ','\\'',$(subst ','\\'',$(NO_GETTEXT)))'\\' >>$@\n-\t@echo GETTEXT_POISON=\\''$(subst ','\\'',$(subst ','\\'',$(GETTEXT_POISON)))'\\' >>$@\n ifdef GIT_PERF_REPEAT_COUNT\n \t@echo GIT_PERF_REPEAT_COUNT=\\''$(subst ','\\'',$(subst ','\\'',$(GIT_PERF_REPEAT_COUNT)))'\\' >>$@\n endif\ndiff --git a/gettext.c b/gettext.c\nindex f75bca7..6aa822c 100644\n--- a/gettext.c\n+++ b/gettext.c\n@@ -16,16 +16,6 @@\n #\tendif\n #endif\n \n-#ifdef GETTEXT_POISON\n-int use_gettext_poison(void)\n-{\n-\tstatic int poison_requested = -1;\n-\tif (poison_requested == -1)\n-\t\tpoison_requested = getenv(\"GIT_GETTEXT_POISON\") ? 1 : 0;\n-\treturn poison_requested;\n-}\n-#endif\n-\n #ifndef NO_GETTEXT\n static void init_gettext_charset(const char *domain)\n {\ndiff --git a/gettext.h b/gettext.h\nindex 57ba8bb..634d8fb 100644\n--- a/gettext.h\n+++ b/gettext.h\n@@ -36,22 +36,14 @@ static inline void git_setup_gettext(void)\n }\n #endif\n \n-#ifdef GETTEXT_POISON\n-extern int use_gettext_poison(void);\n-#else\n-#define use_gettext_poison() 0\n-#endif\n-\n static inline FORMAT_PRESERVING(1) const char *_(const char *msgid)\n {\n-\treturn use_gettext_poison() ? \"# GETTEXT POISON #\" : gettext(msgid);\n+\treturn gettext(msgid);\n }\n \n static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2)\n const char *Q_(const char *msgid, const char *plu, unsigned long n)\n {\n-\tif (use_gettext_poison())\n-\t\treturn \"# GETTEXT POISON #\";\n \treturn ngettext(msgid, plu, n);\n }\n \ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex 6a27f68..d446ba5 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -24,9 +24,6 @@ then\n elif test -n \"$GIT_INTERNAL_GETTEXT_TEST_FALLBACKS\"\n then\n \t: no probing necessary\n-elif test -n \"$GIT_GETTEXT_POISON\"\n-then\n-\tGIT_INTERNAL_GETTEXT_SH_SCHEME=poison\n elif type gettext.sh >/dev/null 2>&1\n then\n \t# GNU libintl's gettext.sh\n@@ -55,17 +52,6 @@ gettext_without_eval_gettext)\n \t\t)\n \t}\n \t;;\n-poison)\n-\t# Emit garbage so that tests that incorrectly rely on translatable\n-\t# strings will fail.\n-\tgettext () {\n-\t\tprintf \"%s\" \"# GETTEXT POISON #\"\n-\t}\n-\n-\teval_gettext () {\n-\t\tprintf \"%s\" \"# GETTEXT POISON #\"\n-\t}\n-\t;;\n *)\n \tgettext () {\n \t\tprintf \"%s\" \"$1\"\ndiff --git a/po/.gitignore b/po/.gitignore\nindex 796b96d..0a4b7fa 100644\n--- a/po/.gitignore\n+++ b/po/.gitignore\n@@ -1 +1,2 @@\n /build\n+/git.pot+\ndiff --git a/po/README b/po/README\nindex c1520e8..7f40b08 100644\n--- a/po/README\n+++ b/po/README\n@@ -270,16 +270,15 @@ something in the test suite might still depend on the US English\n version of the strings, e.g. to grep some error message or other\n output.\n \n-To smoke out issues like these Git can be compiled with gettext poison\n-support, at the top-level:\n+To smoke out issues like these, we can use a podebug [1] utility\n+to generate a pseudotranslation. At top level:\n \n-    make GETTEXT_POISON=YesPlease\n+    # Assume locale \"vi_VN.UTF-8\" is supported by system\n+    make pseudo-locale L=vi\n+    make GETTEXT_POISON=vi_VN.UTF-8 test\n \n That'll give you a git which emits gibberish on every call to\n-gettext. It's obviously not meant to be installed, but you should run\n-the test suite with it:\n-\n-    cd t && prove -j 9 ./t[0-9]*.sh\n+gettext.\n \n If tests break with it you should inspect them manually and see if\n what you're translating is sane, i.e. that you're not translating\n@@ -290,3 +289,5 @@ test_cmp calls with test_i18ncmp. If that's not enough you can skip\n the whole test by making it depend on the C_LOCALE_OUTPUT\n prerequisite. See existing test files with this prerequisite for\n examples.\n+\n+[1] http://translate.sourceforge.net/wiki/toolkit/podebug\ndiff --git a/t/.gitignore b/t/.gitignore\nindex 4e731dc..077b7d5 100644\n--- a/t/.gitignore\n+++ b/t/.gitignore\n@@ -1,3 +1,4 @@\n /trash directory*\n /test-results\n /.prove\n+/test.po*\ndiff --git a/t/lib-gettext.sh b/t/lib-gettext.sh\nindex 0f76f6c..50b5ef9 100644\n--- a/t/lib-gettext.sh\n+++ b/t/lib-gettext.sh\n@@ -5,7 +5,12 @@\n \n . ./test-lib.sh\n \n-GIT_TEXTDOMAINDIR=\"$GIT_BUILD_DIR/po/build/locale\"\n+if test -n \"$GETTEXT_POISON\"\n+then\n+\tGIT_TEXTDOMAINDIR=\"$GIT_BUILD_DIR/po/build/pseudo-locale\"\n+else\n+\tGIT_TEXTDOMAINDIR=\"$GIT_BUILD_DIR/po/build/locale\"\n+fi\n GIT_PO_PATH=\"$GIT_BUILD_DIR/po\"\n export GIT_TEXTDOMAINDIR GIT_PO_PATH\n \ndiff --git a/t/t0200-gettext-basic.sh b/t/t0200-gettext-basic.sh\nindex 8853d8a..572df23 100755\n--- a/t/t0200-gettext-basic.sh\n+++ b/t/t0200-gettext-basic.sh\n@@ -36,6 +36,7 @@ test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=Ye\n '\n \n test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' '\n+    test -n \"$GETTEXT_POISON\" ||\n     test -f \"$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo\"\n '\n \ndiff --git a/t/t0205-gettext-poison.sh b/t/t0205-gettext-poison.sh\ndeleted file mode 100755\nindex 2361590..0000000\n--- a/t/t0205-gettext-poison.sh\n+++ /dev/null\n@@ -1,36 +0,0 @@\n-#!/bin/sh\n-#\n-# Copyright (c) 2010 Ævar Arnfjörð Bjarmason\n-#\n-\n-test_description='Gettext Shell poison'\n-\n-. ./lib-gettext.sh\n-\n-test_expect_success GETTEXT_POISON \"sanity: \\$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)\" '\n-    test -n \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\"\n-'\n-\n-test_expect_success GETTEXT_POISON 'sanity: $GIT_INTERNAL_GETTEXT_SH_SCHEME\" is poison' '\n-    test \"$GIT_INTERNAL_GETTEXT_SH_SCHEME\" = \"poison\"\n-'\n-\n-test_expect_success GETTEXT_POISON 'gettext: our gettext() fallback has poison semantics' '\n-    printf \"# GETTEXT POISON #\" >expect &&\n-    gettext \"test\" >actual &&\n-    test_cmp expect actual &&\n-    printf \"# GETTEXT POISON #\" >expect &&\n-    gettext \"test more words\" >actual &&\n-    test_cmp expect actual\n-'\n-\n-test_expect_success GETTEXT_POISON 'eval_gettext: our eval_gettext() fallback has poison semantics' '\n-    printf \"# GETTEXT POISON #\" >expect &&\n-    eval_gettext \"test\" >actual &&\n-    test_cmp expect actual &&\n-    printf \"# GETTEXT POISON #\" >expect &&\n-    eval_gettext \"test more words\" >actual &&\n-    test_cmp expect actual\n-'\n-\n-test_done\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex bb4f886..b18a079 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -626,7 +626,7 @@ test -z \"$NO_GETTEXT\" && test_set_prereq GETTEXT\n # Can we rely on git's output in the C locale?\n if test -n \"$GETTEXT_POISON\"\n then\n-\tGIT_GETTEXT_POISON=YesPlease\n+\tGIT_GETTEXT_POISON=$GETTEXT_POISON\n \texport GIT_GETTEXT_POISON\n \ttest_set_prereq GETTEXT_POISON\n else\ndiff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\nindex 53a8dd0..a2d9aef 100644\n--- a/wrap-for-bin.sh\n+++ b/wrap-for-bin.sh\n@@ -15,7 +15,15 @@ else\n \texport GIT_TEMPLATE_DIR\n fi\n GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n-GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'\n+if test -n \"$GIT_GETTEXT_POISON\"\n+then\n+\tGIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/pseudo-locale'\n+\tLANG=$GIT_GETTEXT_POISON\n+\tunset LC_ALL\n+\texport LANG\n+else\n+\tGIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'\n+fi\n PATH='@@BUILD_DIR@@/bin-wrappers:'\"$PATH\"\n export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR\n \n-- \n1.7.12.rc2\n"},{"id":"197749","messageId":"1345786986-10826-5-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 4/6] Initialize gettext for test programs that may use it","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:04Z","receivedAt":"2012-08-24T05:43:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Gettext poison was a macro and _() always returned\n\"# GETTEXT POISON #\". Now that we use real gettext(),\nit has to be initialized or it won't work.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n test-date.c             | 1 +\n test-delta.c            | 1 +\n test-dump-cache-tree.c  | 5 ++++-\n test-index-version.c    | 1 +\n test-match-trees.c      | 1 +\n test-mergesort.c        | 1 +\n test-parse-options.c    | 1 +\n test-path-utils.c       | 1 +\n test-revision-walking.c | 1 +\n test-scrap-cache-tree.c | 4 +++-\n test-sha1.c             | 1 +\n test-subprocess.c       | 1 +\n 12 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/test-date.c b/test-date.c\nindex 10afaab..3881d33 100644\n--- a/test-date.c\n+++ b/test-date.c\n@@ -48,6 +48,7 @@ int main(int argc, char **argv)\n \tstruct timeval now;\n \tconst char *x;\n \n+\tgit_setup_gettext();\n \tx = getenv(\"TEST_DATE_NOW\");\n \tif (x) {\n \t\tnow.tv_sec = atoi(x);\ndiff --git a/test-delta.c b/test-delta.c\nindex af40a3c..ac86cae 100644\n--- a/test-delta.c\n+++ b/test-delta.c\n@@ -22,6 +22,7 @@ int main(int argc, char *argv[])\n \tvoid *from_buf, *data_buf, *out_buf;\n \tunsigned long from_size, data_size, out_size;\n \n+\tgit_setup_gettext();\n \tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n \t\tfprintf(stderr, \"Usage: %s\\n\", usage_str);\n \t\treturn 1;\ndiff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c\nindex a6ffdf3..2023475 100644\n--- a/test-dump-cache-tree.c\n+++ b/test-dump-cache-tree.c\n@@ -56,7 +56,10 @@ static int dump_cache_tree(struct cache_tree *it,\n \n int main(int ac, char **av)\n {\n-\tstruct cache_tree *another = cache_tree();\n+\tstruct cache_tree *another;\n+\n+\tgit_setup_gettext();\n+\tanother = cache_tree();\n \tif (read_cache() < 0)\n \t\tdie(\"unable to read index file\");\n \tcache_tree_update(another, active_cache, active_nr, WRITE_TREE_DRY_RUN);\ndiff --git a/test-index-version.c b/test-index-version.c\nindex bfaad9e..703f4bd 100644\n--- a/test-index-version.c\n+++ b/test-index-version.c\n@@ -5,6 +5,7 @@ int main(int argc, const char **argv)\n \tstruct cache_header hdr;\n \tint version;\n \n+\tgit_setup_gettext();\n \tmemset(&hdr,0,sizeof(hdr));\n \tif (read(0, &hdr, sizeof(hdr)) != sizeof(hdr))\n \t\treturn 0;\ndiff --git a/test-match-trees.c b/test-match-trees.c\nindex a3c4688..5299292 100644\n--- a/test-match-trees.c\n+++ b/test-match-trees.c\n@@ -6,6 +6,7 @@ int main(int ac, char **av)\n \tunsigned char hash1[20], hash2[20], shifted[20];\n \tstruct tree *one, *two;\n \n+\tgit_setup_gettext();\n \tif (get_sha1(av[1], hash1))\n \t\tdie(\"cannot parse %s as an object name\", av[1]);\n \tif (get_sha1(av[2], hash2))\ndiff --git a/test-mergesort.c b/test-mergesort.c\nindex 3f388b4..2289cb1 100644\n--- a/test-mergesort.c\n+++ b/test-mergesort.c\n@@ -27,6 +27,7 @@ int main(int argc, const char **argv)\n \tstruct line *line, *p = NULL, *lines = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\n \n+\tgit_setup_gettext();\n \tfor (;;) {\n \t\tif (strbuf_getwholeline(&sb, stdin, '\\n'))\n \t\t\tbreak;\ndiff --git a/test-parse-options.c b/test-parse-options.c\nindex 3c9510a..4a94327 100644\n--- a/test-parse-options.c\n+++ b/test-parse-options.c\n@@ -81,6 +81,7 @@ int main(int argc, const char **argv)\n \t};\n \tint i;\n \n+\tgit_setup_gettext();\n \targc = parse_options(argc, argv, prefix, options, usage, 0);\n \n \tprintf(\"boolean: %d\\n\", boolean);\ndiff --git a/test-path-utils.c b/test-path-utils.c\nindex 3bc20e9..f3b4cee 100644\n--- a/test-path-utils.c\n+++ b/test-path-utils.c\n@@ -2,6 +2,7 @@\n \n int main(int argc, char **argv)\n {\n+\tgit_setup_gettext();\n \tif (argc == 3 && !strcmp(argv[1], \"normalize_path_copy\")) {\n \t\tchar *buf = xmalloc(PATH_MAX + 1);\n \t\tint rv = normalize_path_copy(buf, argv[2]);\ndiff --git a/test-revision-walking.c b/test-revision-walking.c\nindex 3ade02c..5f476c0 100644\n--- a/test-revision-walking.c\n+++ b/test-revision-walking.c\n@@ -47,6 +47,7 @@ static int run_revision_walk(void)\n \n int main(int argc, char **argv)\n {\n+\tgit_setup_gettext();\n \tif (argc < 2)\n \t\treturn 1;\n \ndiff --git a/test-scrap-cache-tree.c b/test-scrap-cache-tree.c\nindex 4728013..67234e1 100644\n--- a/test-scrap-cache-tree.c\n+++ b/test-scrap-cache-tree.c\n@@ -6,7 +6,9 @@ static struct lock_file index_lock;\n \n int main(int ac, char **av)\n {\n-\tint fd = hold_locked_index(&index_lock, 1);\n+\tint fd;\n+\tgit_setup_gettext();\n+\tfd = hold_locked_index(&index_lock, 1);\n \tif (read_cache() < 0)\n \t\tdie(\"unable to read index file\");\n \tactive_cache_tree = NULL;\ndiff --git a/test-sha1.c b/test-sha1.c\nindex 80daba9..9a02ce8 100644\n--- a/test-sha1.c\n+++ b/test-sha1.c\n@@ -7,6 +7,7 @@ int main(int ac, char **av)\n \tunsigned bufsz = 8192;\n \tchar *buffer;\n \n+\tgit_setup_gettext();\n \tif (ac == 2)\n \t\tbufsz = strtoul(av[1], NULL, 10) * 1024 * 1024;\n \ndiff --git a/test-subprocess.c b/test-subprocess.c\nindex f2d4c0d..9cf8e29 100644\n--- a/test-subprocess.c\n+++ b/test-subprocess.c\n@@ -6,6 +6,7 @@ int main(int argc, const char **argv)\n \tstruct child_process cp;\n \tint nogit = 0;\n \n+\tgit_setup_gettext();\n \tsetup_git_directory_gently(&nogit);\n \tif (nogit)\n \t\tdie(\"No git repo found\");\n-- \n1.7.12.rc2\n"},{"id":"197750","messageId":"1345786986-10826-6-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 5/6] Support logging unmarked strings","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:05Z","receivedAt":"2012-08-24T05:43:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Hard coding path obviously won't fly..\n\n .gitignore      | 1 +\n wrap-for-bin.sh | 6 ++++++\n 2 files changed, 7 insertions(+)\n\ndiff --git a/.gitignore b/.gitignore\nindex bb5c91e..f2d0fe5 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -195,6 +195,7 @@\n /test-sigchain\n /test-subprocess\n /test-svn-fe\n+/untranslated.log\n /common-cmds.h\n *.tar.gz\n *.dsc\ndiff --git a/wrap-for-bin.sh b/wrap-for-bin.sh\nindex a2d9aef..4dbae80 100644\n--- a/wrap-for-bin.sh\n+++ b/wrap-for-bin.sh\n@@ -17,6 +17,12 @@ fi\n GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'\n if test -n \"$GIT_GETTEXT_POISON\"\n then\n+\tif test -x /usr/lib/preloadable_libintl.so\n+\tthen\n+\t\tGETTEXT_LOG_UNTRANSLATED=@@BUILD_DIR@@/untranslated.log\n+\t\tLD_PRELOAD=\"/usr/lib/preloadable_libintl.so $LD_PRELOAD\"\n+\t\texport LD_PRELOAD GETTEXT_LOG_UNTRANSLATED\n+\tfi\n \tGIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/pseudo-locale'\n \tLANG=$GIT_GETTEXT_POISON\n \tunset LC_ALL\n-- \n1.7.12.rc2\n"},{"id":"197751","messageId":"1345786986-10826-7-git-send-email-pclouds@gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 6/6] test-parse-options: mark parseopt help strings for pseudotranslation","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T05:43:06Z","receivedAt":"2012-08-24T05:43:06Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This reduces the number of false positives in untranslated.log when we\ncheck for unmarked strings.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n test-parse-options.c | 62 ++++++++++++++++++++++++++--------------------------\n 1 file changed, 31 insertions(+), 31 deletions(-)\n\ndiff --git a/test-parse-options.c b/test-parse-options.c\nindex 4a94327..09ddf74 100644\n--- a/test-parse-options.c\n+++ b/test-parse-options.c\n@@ -33,50 +33,50 @@ int main(int argc, const char **argv)\n {\n \tconst char *prefix = \"prefix/\";\n \tconst char *usage[] = {\n-\t\t\"test-parse-options <options>\",\n+\t\tN_(\"test-parse-options <options>\"),\n \t\tNULL\n \t};\n \tstruct option options[] = {\n-\t\tOPT_BOOL(0, \"yes\", &boolean, \"get a boolean\"),\n-\t\tOPT_BOOL('D', \"no-doubt\", &boolean, \"begins with 'no-'\"),\n+\t\tOPT_BOOL(0, \"yes\", &boolean, N_(\"get a boolean\")),\n+\t\tOPT_BOOL('D', \"no-doubt\", &boolean, N_(\"begins with 'no-'\")),\n \t\t{ OPTION_SET_INT, 'B', \"no-fear\", &boolean, NULL,\n-\t\t  \"be brave\", PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },\n-\t\tOPT_COUNTUP('b', \"boolean\", &boolean, \"increment by one\"),\n+\t\t  N_(\"be brave\"), PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, 1 },\n+\t\tOPT_COUNTUP('b', \"boolean\", &boolean, N_(\"increment by one\")),\n \t\tOPT_BIT('4', \"or4\", &boolean,\n-\t\t\t\"bitwise-or boolean with ...0100\", 4),\n-\t\tOPT_NEGBIT(0, \"neg-or4\", &boolean, \"same as --no-or4\", 4),\n+\t\t\tN_(\"bitwise-or boolean with ...0100\"), 4),\n+\t\tOPT_NEGBIT(0, \"neg-or4\", &boolean, N_(\"same as --no-or4\"), 4),\n \t\tOPT_GROUP(\"\"),\n-\t\tOPT_INTEGER('i', \"integer\", &integer, \"get a integer\"),\n-\t\tOPT_INTEGER('j', NULL, &integer, \"get a integer, too\"),\n-\t\tOPT_SET_INT(0, \"set23\", &integer, \"set integer to 23\", 23),\n-\t\tOPT_DATE('t', NULL, &timestamp, \"get timestamp of <time>\"),\n-\t\tOPT_CALLBACK('L', \"length\", &integer, \"str\",\n-\t\t\t\"get length of <str>\", length_callback),\n-\t\tOPT_FILENAME('F', \"file\", &file, \"set file to <file>\"),\n-\t\tOPT_GROUP(\"String options\"),\n-\t\tOPT_STRING('s', \"string\", &string, \"string\", \"get a string\"),\n-\t\tOPT_STRING(0, \"string2\", &string, \"str\", \"get another string\"),\n-\t\tOPT_STRING(0, \"st\", &string, \"st\", \"get another string (pervert ordering)\"),\n-\t\tOPT_STRING('o', NULL, &string, \"str\", \"get another string\"),\n+\t\tOPT_INTEGER('i', \"integer\", &integer, N_(\"get a integer\")),\n+\t\tOPT_INTEGER('j', NULL, &integer, N_(\"get a integer, too\")),\n+\t\tOPT_SET_INT(0, \"set23\", &integer, N_(\"set integer to 23\"), 23),\n+\t\tOPT_DATE('t', NULL, &timestamp, N_(\"get timestamp of <time>\")),\n+\t\tOPT_CALLBACK('L', \"length\", &integer, N_(\"str\"),\n+\t\t\tN_(\"get length of <str>\"), length_callback),\n+\t\tOPT_FILENAME('F', \"file\", &file, N_(\"set file to <file>\")),\n+\t\tOPT_GROUP(N_(\"String options\")),\n+\t\tOPT_STRING('s', \"string\", &string, N_(\"string\"), N_(\"get a string\")),\n+\t\tOPT_STRING(0, \"string2\", &string, N_(\"str\"), N_(\"get another string\")),\n+\t\tOPT_STRING(0, \"st\", &string, N_(\"st\"), N_(\"get another string (pervert ordering)\")),\n+\t\tOPT_STRING('o', NULL, &string, N_(\"str\"), N_(\"get another string\")),\n \t\tOPT_NOOP_NOARG(0, \"obsolete\"),\n \t\tOPT_SET_PTR(0, \"default-string\", &string,\n-\t\t\t\"set string to default\", (unsigned long)\"default\"),\n-\t\tOPT_STRING_LIST(0, \"list\", &list, \"str\", \"add str to list\"),\n-\t\tOPT_GROUP(\"Magic arguments\"),\n-\t\tOPT_ARGUMENT(\"quux\", \"means --quux\"),\n-\t\tOPT_NUMBER_CALLBACK(&integer, \"set integer to NUM\",\n+\t\t\tN_(\"set string to default\"), (unsigned long)\"default\"),\n+\t\tOPT_STRING_LIST(0, \"list\", &list, N_(\"str\"), N_(\"add str to list\")),\n+\t\tOPT_GROUP(N_(\"Magic arguments\")),\n+\t\tOPT_ARGUMENT(\"quux\", N_(\"means --quux\")),\n+\t\tOPT_NUMBER_CALLBACK(&integer, N_(\"set integer to NUM\"),\n \t\t\tnumber_callback),\n-\t\t{ OPTION_COUNTUP, '+', NULL, &boolean, NULL, \"same as -b\",\n+\t\t{ OPTION_COUNTUP, '+', NULL, &boolean, NULL, N_(\"same as -b\"),\n \t\t  PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH },\n \t\t{ OPTION_COUNTUP, 0, \"ambiguous\", &ambiguous, NULL,\n-\t\t  \"positive ambiguity\", PARSE_OPT_NOARG | PARSE_OPT_NONEG },\n+\t\t  N_(\"positive ambiguity\"), PARSE_OPT_NOARG | PARSE_OPT_NONEG },\n \t\t{ OPTION_COUNTUP, 0, \"no-ambiguous\", &ambiguous, NULL,\n-\t\t  \"negative ambiguity\", PARSE_OPT_NOARG | PARSE_OPT_NONEG },\n-\t\tOPT_GROUP(\"Standard options\"),\n+\t\t  N_(\"negative ambiguity\"), PARSE_OPT_NOARG | PARSE_OPT_NONEG },\n+\t\tOPT_GROUP(N_(\"Standard options\")),\n \t\tOPT__ABBREV(&abbrev),\n-\t\tOPT__VERBOSE(&verbose, \"be verbose\"),\n-\t\tOPT__DRY_RUN(&dry_run, \"dry run\"),\n-\t\tOPT__QUIET(&quiet, \"be quiet\"),\n+\t\tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n+\t\tOPT__DRY_RUN(&dry_run, N_(\"dry run\")),\n+\t\tOPT__QUIET(&quiet, N_(\"be quiet\")),\n \t\tOPT_END(),\n \t};\n \tint i;\n-- \n1.7.12.rc2\n"},{"id":"197754","messageId":"CACBZZX7V3A02sPQex4zpBE8Tkmc2d037tJBfhn-6DeK_MwY2Hw@mail.gmail.com","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 0/6] Gettext poison rework","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-08-24T08:51:45Z","receivedAt":"2012-08-24T08:51:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, Aug 24, 2012 at 7:43 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> Still WIP but I'm getting closer. I dropped test-poisongen and started\n> to use podebug [2] instead. Less code in git. podebug does not preserve\n> shell variables yet. I'll follow that up at upstream [1].\n>\n> With this series, if you have translation toolkit installed, you could\n> do\n>\n>     make pseudo-locale L=<your language code>\n>     make GETTEXT_POISON=$LANG test\n>\n> podebug supports a few way of rewriting translations. Currently\n> \"unicode\" is used but you can change it via PODEBUG_OPTS\n>\n> t9001 is not happy with $LANG != C though. May need to add some\n> prereq there.\n>\n> [1] http://bugs.locamotion.org/show_bug.cgi?id=2450\n> [2] http://translate.sourceforge.net/wiki/toolkit/podebug\n\nThe reason I didn't do something like this to begin with is that\ngettext/glibc doesn't have support for fake locales, so you'd have to\nappropriate a real one for tests. It's good to see you poking the\ngettext mailing list about adding support far thot.\n\nBut something like podebug gets around that quite nicely, so we can\nstill have the testing the poison stuff was intended for, without the\ncomplexity of supporting it throughout all our i18n code.\n"},{"id":"197766","messageId":"CACsJy8CEmafo3mXB7nS8MxN-yMwpsPEan5OU0K=SJi0jm4MtxQ@mail.gmail.com","threadId":"31337","inReplyTo":"CACBZZX7V3A02sPQex4zpBE8Tkmc2d037tJBfhn-6DeK_MwY2Hw@mail.gmail.com","subject":"Re: [PATCH 0/6] Gettext poison rework","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-08-24T10:54:28Z","receivedAt":"2012-08-24T10:54:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Aug 24, 2012 at 3:51 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>> [1] http://bugs.locamotion.org/show_bug.cgi?id=2450\n>> [2] http://translate.sourceforge.net/wiki/toolkit/podebug\n>\n> The reason I didn't do something like this to begin with is that\n> gettext/glibc doesn't have support for fake locales, so you'd have to\n> appropriate a real one for tests. It's good to see you poking the\n> gettext mailing list about adding support far thot.\n\nI don't see glibc getting fake locale support any time soon even if\nit's more open than before. I can try to make gettext support pseudo\ntranslations, though not sure if I can make it.\n\n> But something like podebug gets around that quite nicely, so we can\n> still have the testing the poison stuff was intended for, without the\n> complexity of supporting it throughout all our i18n code.\n\nBut yes, even if gettext does not have native support, relying on\npodebug should be ok. Whatever changes we need, other projects might\ntoo. It's better to do it outside of git.\n-- \nDuy1\n"},{"id":"197779","messageId":"7vwr0o1doj.fsf@alter.siamese.dyndns.org","threadId":"31337","inReplyTo":"1345786986-10826-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 0/6] Gettext poison rework","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-24T16:02:04Z","receivedAt":"2012-08-24T16:02:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> Still WIP but I'm getting closer. I dropped test-poisongen and started\n> to use podebug [2] instead. Less code in git. podebug does not preserve\n> shell variables yet. I'll follow that up at upstream [1].\n\nThanks; this looks promising.\n"}]}