{"thread":{"id":"30693","subject":"[PATCH 1/2] i18n: Extract msgs marked by sh gettext wrappers","startedAt":"2012-06-03T23:09:26Z","lastAt":"2012-06-15T18:13:39Z","messageCount":8,"participants":["Jiang Xin","Ævar Arnfjörð Bjarmason","Junio C Hamano","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"192780","messageId":"1338764967-30103-1-git-send-email-worldhello.net@gmail.com","threadId":"30693","inReplyTo":null,"subject":"[PATCH 1/2] i18n: Extract msgs marked by sh gettext wrappers","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2012-06-03T23:09:26Z","receivedAt":"2012-06-03T23:09:26Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"Since we have additional shell wrappers (gettextln and eval_gettextln)\nfor gettext, we need to take into account these wrapers when run\n'make pot' to extract messages from shell scripts.\n\nSigned-off-by: Jiang Xin <worldhello.net@gmail.com>\n---\n Makefile | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 4592f..dc3fd 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2333,7 +2333,8 @@ XGETTEXT_FLAGS = \\\n \t--from-code=UTF-8\n XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \\\n \t--keyword=_ --keyword=N_ --keyword=\"Q_:1,2\"\n-XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell\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) $(XDIFF_H) $(VCSSVN_H) $(MISC_H)\n LOCALIZED_SH := $(SCRIPT_SH)\n-- \n1.7.10.2.559.g0ba0f00\n"},{"id":"192781","messageId":"1338764967-30103-2-git-send-email-worldhello.net@gmail.com","threadId":"30693","inReplyTo":"1338764967-30103-1-git-send-email-worldhello.net@gmail.com","subject":"[PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2012-06-03T23:09:27Z","receivedAt":"2012-06-03T23:09:27Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"In commit b9b9c22, Ævar addressed a issue when gettextized a message\nstarted with \"--\", such as \"--cached cannot be used with --files\", the\nfirst word in the message would be treated as an option of gettext, and\nmight raise a bad option error.\n\nThe solution Ævar provided is to add a extra \"--\" option between gettext\nand the message. But Vincent fount out later that the extra \"--\" was\nextracted as gettext message by xgettext instead of the real message.\nSee:\n\n * http://thread.gmane.org/gmane.comp.version-control.git/199042\n\nIn order to fix this dilemma, we move the extra \"--\" option from gettext\nto gettext wrapper (gettextln, and eval_gettext), and gettextize the\nmessage using the wrapper function instead of gettext itself.\n\nBut for system with libintl's gettext.sh, eval_gettext and\neval_gettextln won't have this fix.\n\nSigned-off-by: Jiang Xin <worldhello.net@gmail.com>\nSigned-off-by: Andreas Schwab <schwab@linux-m68k.org>\n---\n git-sh-i18n.sh   | 8 ++++++--\n git-submodule.sh | 2 +-\n 2 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/git-sh-i18n.sh b/git-sh-i18n.sh\nindex 6a27f..1c61e4 100644\n--- a/git-sh-i18n.sh\n+++ b/git-sh-i18n.sh\n@@ -49,7 +49,7 @@ gnu)\n gettext_without_eval_gettext)\n \t# Solaris has a gettext(1) but no eval_gettext(1)\n \teval_gettext () {\n-\t\tgettext \"$1\" | (\n+\t\tgettext -- \"$1\" | (\n \t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n \t\t\tgit sh-i18n--envsubst \"$1\"\n \t\t)\n@@ -68,10 +68,14 @@ poison)\n \t;;\n *)\n \tgettext () {\n+\t\t# Bypass options, such as '--'.\n+\t\tshift $(($# - 1))\n \t\tprintf \"%s\" \"$1\"\n \t}\n \n \teval_gettext () {\n+\t\t# Bypass options, such as '--'.\n+\t\tshift $(($# - 1))\n \t\tprintf \"%s\" \"$1\" | (\n \t\t\texport PATH $(git sh-i18n--envsubst --variables \"$1\");\n \t\t\tgit sh-i18n--envsubst \"$1\"\n@@ -82,7 +86,7 @@ esac\n \n # Git-specific wrapper functions\n gettextln () {\n-\tgettext \"$1\"\n+\tgettext -- \"$1\"\n \techo\n }\n \ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 5c61a..bb9f6 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -710,7 +710,7 @@ cmd_summary() {\n \tif [ -n \"$files\" ]\n \tthen\n \t\ttest -n \"$cached\" &&\n-\t\tdie \"$(gettext -- \"--cached cannot be used with --files\")\"\n+\t\tdie \"$(gettextln \"--cached cannot be used with --files\")\"\n \t\tdiff_cmd=diff-files\n \t\thead=\n \tfi\n-- \n1.7.10.2.559.g0ba0f00\n"},{"id":"192787","messageId":"CACBZZX5EGvJm0aqG5iVn7wnoqFATUqP4gbS-2tnAiLqeFQZifg@mail.gmail.com","threadId":"30693","inReplyTo":"1338764967-30103-2-git-send-email-worldhello.net@gmail.com","subject":"Re: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-06-04T08:56:08Z","receivedAt":"2012-06-04T08:56:08Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Jun 4, 2012 at 1:09 AM, Jiang Xin <worldhello.net@gmail.com> wrote:\n> In commit b9b9c22, Ævar addressed a issue when gettextized a message\n> started with \"--\", such as \"--cached cannot be used with --files\", the\n> first word in the message would be treated as an option of gettext, and\n> might raise a bad option error.\n>\n> The solution Ævar provided is to add a extra \"--\" option between gettext\n> and the message. But Vincent fount out later that the extra \"--\" was\n> extracted as gettext message by xgettext instead of the real message.\n> See:\n>\n>  * http://thread.gmane.org/gmane.comp.version-control.git/199042\n>\n> In order to fix this dilemma, we move the extra \"--\" option from gettext\n> to gettext wrapper (gettextln, and eval_gettext), and gettextize the\n> message using the wrapper function instead of gettext itself.\n>\n> But for system with libintl's gettext.sh, eval_gettext and\n> eval_gettextln won't have this fix.\n\nI think a better solution to this is to just apply this patch:\n\n-               die \"$(gettext -- \"--cached cannot be used with --files\")\"\n+               die \"$(gettext \"the --cached option is incompatible\nwith the --files option\")\"\n\nIt's one message only, and this is due to a bug in the xgettext\nextraction. I think changing the only message suffering from this\nissue (or likely to suffer from it) beats a solution where starting a\nmessage with -- only works for some of the xgettext\ncommands/functions.\n"},{"id":"192803","messageId":"CANYiYbFx=Z7TTYUbAhzgHFYB6O_grROWoWHbtuhuABeXdFk4-Q@mail.gmail.com","threadId":"30693","inReplyTo":"CACBZZX5EGvJm0aqG5iVn7wnoqFATUqP4gbS-2tnAiLqeFQZifg@mail.gmail.com","subject":"Re: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2012-06-04T13:55:11Z","receivedAt":"2012-06-04T13:55:11Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"2012/6/4 Ævar Arnfjörð Bjarmason <avarab@gmail.com>:\n> I think a better solution to this is to just apply this patch:\n>\n> -               die \"$(gettext -- \"--cached cannot be used with --files\")\"\n> +               die \"$(gettext \"the --cached option is incompatible\n> with the --files option\")\"\n\nThe rewrite message is a bit odd for there are 40 more alike\nmessages (extracted from C files) start with \"--”, such as:\n\n    msgid \"--delete only accepts plain target ref names\"\n    msgid \"--all and --tags are incompatible\"\n    msgid \"--all can't be combined with refspecs\"\n    msgid \"--mirror and --tags are incompatible\"\n    msgid \"--mirror can't be combined with refspecs\"\n\n> I think changing the only message suffering from this\n> issue (or likely to suffer from it) beats a solution where starting a\n> message with -- only works for some of the xgettext\n> commands/functions.\n\nIf I had not changed like this, I would not find out there are 27\nmarked messages (by gettext wrappers) have not been\nextracted to \"po/git.pot\". ;-)\n\n-- \nJiang Xin\n"},{"id":"192815","messageId":"7vpq9ft3ls.fsf@alter.siamese.dyndns.org","threadId":"30693","inReplyTo":"CANYiYbFx=Z7TTYUbAhzgHFYB6O_grROWoWHbtuhuABeXdFk4-Q@mail.gmail.com","subject":"Re: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-04T16:59:43Z","receivedAt":"2012-06-04T16:59:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jiang Xin <worldhello.net@gmail.com> writes:\n\n> 2012/6/4 Ævar Arnfjörð Bjarmason <avarab@gmail.com>:\n>> I think a better solution to this is to just apply this patch:\n>>\n>> -               die \"$(gettext -- \"--cached cannot be used with --files\")\"\n>> +               die \"$(gettext \"the --cached option is incompatible\n>> with the --files option\")\"\n>\n> The rewrite message is a bit odd for there are 40 more alike\n> messages (extracted from C files) start with \"--”, such as:\n>\n>     msgid \"--delete only accepts plain target ref names\"\n>     msgid \"--all and --tags are incompatible\"\n>     msgid \"--all can't be combined with refspecs\"\n>     msgid \"--mirror and --tags are incompatible\"\n>     msgid \"--mirror can't be combined with refspecs\"\n>\n>> I think changing the only message suffering from this\n>> issue (or likely to suffer from it) beats a solution where starting a\n>> message with -- only works for some of the xgettext\n>> commands/functions.\n>\n> If I had not changed like this, I would not find out there are 27\n> marked messages (by gettext wrappers) have not been\n> extracted to \"po/git.pot\". ;-)\n\nI think there is value for having a generic solution than declaring\n\"No message shall begin with a dash\".\n\nI am not convinced that it is ideal for the implementation of\ngettext_ln to prepend \"--\" in front when it calls gettext, though.\nShouldn't the caller of gettext_ln be the one who is responsible for\ndoing that?  After all, that is the one that knows that the MSGID\nargument needs the quoting.\n"},{"id":"193705","messageId":"CANYiYbGnoZDMkOq-goaPO98L4Ar1HzMVS-JjjBz7rNHVgv4ywQ@mail.gmail.com","threadId":"30693","inReplyTo":"7vpq9ft3ls.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2012-06-15T16:05:53Z","receivedAt":"2012-06-15T16:05:53Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"2012/6/5 Junio C Hamano <gitster@pobox.com>:\n> I think there is value for having a generic solution than declaring\n> \"No message shall begin with a dash\".\n>\n> I am not convinced that it is ideal for the implementation of\n> gettext_ln to prepend \"--\" in front when it calls gettext, though.\n\nI saw Ævar's bug report on xgettext to the GNU gettext list:\n\n * http://git.661346.n2.nabble.com/GETTEXT-BUG-xgettext-1-can-t-extract-quot-gettext-foo-quot-td7560744.html\n\nMay be post to a more official mailing list, such as bug-gnu-utils at\nhttps://lists.gnu.org/mailman/listinfo/bug-gnu-utils will get some response,\nbut I doubt there won't be a clear resolution in xgettext.\n\nThe default configurations of xgettext for shell scripts are defined in file\n'gettext-tools/src/x-sh.c':\n\n      x_sh_keyword (\"gettext\");\n      x_sh_keyword (\"ngettext:1,2\");\n      x_sh_keyword (\"eval_gettext\");\n      x_sh_keyword (\"eval_ngettext:1,2\");\n\nKeyword \"gettext\" above is the same as \"gettext:1\". xgettext has\nno idea of options and arguments, if there is a seperator ('--') between\ngettext and the message, message is argument 2. For example:\n\n    gettext -- \"--cached cannot be used with --files\"\n\nWe can override the default settings of xgettext by passing '-k' and\nmultiple '--keyword', '--flags' options to xgettext.\n\n    xgettext  ... --language=Shell \\\n                  -k  --keyword=gettext:2 \\\n                  --flag=gettext:2:pass-sh-format  ...\n\nBut \"gettext message\" will be broken.\n\nWrite a wrapper for gettext  and extract messages using\n'xgettext --keyword=<gettext-wrapper>' is a reasonable solution.\n\n\n-- \nJiang Xin\n"},{"id":"193710","messageId":"20120615174149.GG10752@burratino","threadId":"30693","inReplyTo":"CANYiYbGnoZDMkOq-goaPO98L4Ar1HzMVS-JjjBz7rNHVgv4ywQ@mail.gmail.com","subject":"Re: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2012-06-15T17:41:49Z","receivedAt":"2012-06-15T17:41:49Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jiang Xin wrote:\n\n> I saw Ævar's bug report on xgettext to the GNU gettext list:\n>\n>  * http://git.661346.n2.nabble.com/GETTEXT-BUG-xgettext-1-can-t-extract-quot-gettext-foo-quot-td7560744.html\n>\n> May be post to a more official mailing list, such as bug-gnu-utils at\n> https://lists.gnu.org/mailman/listinfo/bug-gnu-utils will get some response,\n\nI think bug-gettext is the right place:\nhttp://lists.gnu.org/archive/html/bug-gettext/2012-06/msg00003.html\n\n> but I doubt there won't be a clear resolution in xgettext.\n\nThe double negative is leaving me confused. :)  Are you saying you\ndoubt that anyone will come up with a patch to fix xgettext, or that\nyou doubt that the result will be satisfactory?\n\n[...]\n> Write a wrapper for gettext  and extract messages using\n> 'xgettext --keyword=<gettext-wrapper>' is a reasonable solution.\n\nFor what it's worth that does seem to me like the most sensible\nworkaround in the short term. :/\n\n\tgittext () {\t# or sane_gettext or literal_gettext or something\n\t\tgettext -- \"$1\"\n\t}\n\n\tgittextln () {\n\t\tgettext -- \"$1\"\n\t\techo\n\t}\n\nThanks,\nJonathan\n"},{"id":"193715","messageId":"7v62asbfzg.fsf@alter.siamese.dyndns.org","threadId":"30693","inReplyTo":"20120615174149.GG10752@burratino","subject":"Re: [PATCH 2/2] i18n: Add extra -- to seperate gettext and message","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-15T18:13:39Z","receivedAt":"2012-06-15T18:13:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> For what it's worth that does seem to me like the most sensible\n> workaround in the short term. :/\n>\n> \tgittext () {\t# or sane_gettext or literal_gettext or something\n> \t\tgettext -- \"$1\"\n> \t}\n>\n> \tgittextln () {\n> \t\tgettext -- \"$1\"\n> \t\techo\n> \t}\n>\n> Thanks,\n> Jonathan\n\nThanks for rephrasing ;-)  That \"g*I*ttext\" looks a bit too cute for\nmy taste, but something along that line does seem to be a reasonable\nway forward.\n"}]}