{"thread":{"id":"27371","subject":"Bikeshedding advice on the ab/i18n-scripts series","startedAt":"2011-05-16T16:03:30Z","lastAt":"2011-05-16T21:40:33Z","messageCount":9,"participants":["Ævar Arnfjörð Bjarmason","Jonathan Nieder","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"168001","messageId":"BANLkTi==pxyy7OeZT0mn33iJHrc5R7vHBw@mail.gmail.com","threadId":"27371","inReplyTo":null,"subject":"Bikeshedding advice on the ab/i18n-scripts series","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-05-16T16:03:30Z","receivedAt":"2011-05-16T16:03:30Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, May 11, 2011 at 22:24, Junio C Hamano <gitster@pobox.com> wrote:\n\n> Will merge to \"master\" by the end of week #3.\n>\n> * ab/i18n-scripts (2011-05-08) 48 commits\n>  - i18n: git-bisect bisect_next_check \"You need to\" message\n>  - i18n: git-bisect [Y/n] messages\n>  - i18n: git-bisect bisect_replay + $1 messages\n\nI'm now mostly done solving all the bugs noted in this series, aside\nfrom the case insensitive env vars on win32 issue.\n\nI know how to fix these, but some people may have issues with my style\nof doing so, so I'd like to ask in advance to save me extra work.\n\nBasically for code like this:\n\n        while [ $# -gt 0 ]; do\n            arg=\"$1\"\n            case \"$arg\" in\n            --)\n                shift\n                break\n                ;;\n            *)\n                rev=$(git rev-parse -q --verify \"$arg^{commit}\") || {\n                    test $has_double_dash -eq 1 &&\n                        die \"$(eval_gettext \"'\\$arg' does not appear\nto be a valid revision\")\"\n                    break\n\nI was thinking of just doing:\n\n    WHATEVER_arg=$arg\n    die \"$(eval_gettext \"'\\$WHATEVER_arg' does not appear to be a\nvalid revision\")\"\n\nWhere WHATEVER is a sufficiently unique prefix. E.g.:\n\n    WINDOWS_ME_HARDER\n    GIT_I18N_VARIABLE\n    YOUR_MOM\n    DUDE_WHERES_MY_POSIX_COMPLIANCE\n\nI'll just pick one at my discretion (not necessarily from that list)\nunless someone has some strong preference. I don't care, I just don't\nwant to re-send it over that.\n\nI could also change all occurances of \"arg\" (including arg=\"$1\" etc.)\nto WHATEVER_arg, but that seems like overkill, and would make the code\nhard to read, since you'd have WHATEVER all over the place.\n\nOh, and for all the convertion of:\n\n    echo >&2 \"$(gettext \"foobar\")\"\n\nI've already done:\n\n    (\n        gettext \"foobar\" &&\n        echo\n    ) >&2\n\nIs that OK, or does someone have a strong preference (and wants me to\nwaste time on converting it) for:\n\n    gettext \"foobar\" >&2\n    echo >&2\n\nOr something else?\n\nYour friendly neighborhood i18n maintainer.\n"},{"id":"168002","messageId":"20110516162600.GA25468@elie","threadId":"27371","inReplyTo":"BANLkTi==pxyy7OeZT0mn33iJHrc5R7vHBw@mail.gmail.com","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-05-16T16:26:00Z","receivedAt":"2011-05-16T16:26:00Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n\n> Oh, and for all the convertion of:\n>\n>     echo >&2 \"$(gettext \"foobar\")\"\n>\n> I've already done:\n>\n>     (\n>         gettext \"foobar\" &&\n>         echo\n>     ) >&2\n\nSome day we might want to introduce a gettext_ln function or something\nsimilar.  But that doesn't seem urgent; I wouldn't be appalled by\nhaving to read 'gettext \"foobar\" && echo' in a block surrounded by\nbraces (or even a subshell, even though it makes shells waste a\nfork()).\n\nAs for what to call the envvars, I have no strong preference there,\neither.  If you don't care about compatibility with the real gettext.sh\nthen it should be possible to do the variable munging automatically,\nusing a loop:\n\n\tfor var in $(git sh-i18n--envsubst --variables \"$fmt\")\n\tdo\n\t\teval \"sh_i18n_$var\"=\\$var\n\t\texport \"sh_i18n_$var\"\n\tdone\n\nwith an understanding that git sh-i18n--envsubst substitutes in\n${sh_i18n_$var} where it sees '$var' in the format string.\n\nBut if we do want to use the real envsubst some day then that is not\npossible.  I dunno.\n"},{"id":"168015","messageId":"7vboz2l6h1.fsf@alter.siamese.dyndns.org","threadId":"27371","inReplyTo":"BANLkTi==pxyy7OeZT0mn33iJHrc5R7vHBw@mail.gmail.com","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-16T20:45:46Z","receivedAt":"2011-05-16T20:45:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Oh, and for all the convertion of:\n>\n>     echo >&2 \"$(gettext \"foobar\")\"\n>\n> I've already done:\n>\n>     (\n>         gettext \"foobar\" &&\n>         echo\n>     ) >&2\n\nSorry, but what problem are you trying to solve?  The output from\n\n    $ gettext \"foobar\"\n\nmay have 0, 1 or more LF at the end, but wouldn't \n\n    echo >&2 \"$(gettext \"foobar\")\"\n\nterminate with a single LF in any case?\n\nAhh, perhaps I was the one who said something stupid like:\n\n\techo >&2 \"$(cmd)\"\n\nshould be equivalent to\n\n\tcmd >&2\n\nwhich is not the case when output from cmd does not end with a single LF\n(i.e. either an incomplete line, or with trailing blank lines).\n\nSorry, if that is what you are trying to address, please let me take that\nback.\n"},{"id":"168016","messageId":"BANLkTimtofA7xVBW-W+20zqUt98GLSPHdw@mail.gmail.com","threadId":"27371","inReplyTo":"7vboz2l6h1.fsf@alter.siamese.dyndns.org","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-05-16T20:53:44Z","receivedAt":"2011-05-16T20:53:44Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, May 16, 2011 at 22:45, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> Oh, and for all the convertion of:\n>>\n>>     echo >&2 \"$(gettext \"foobar\")\"\n>>\n>> I've already done:\n>>\n>>     (\n>>         gettext \"foobar\" &&\n>>         echo\n>>     ) >&2\n>\n> Sorry, but what problem are you trying to solve?  The output from\n>\n>    $ gettext \"foobar\"\n>\n> may have 0, 1 or more LF at the end, but wouldn't\n>\n>    echo >&2 \"$(gettext \"foobar\")\"\n>\n> terminate with a single LF in any case?\n>\n> Ahh, perhaps I was the one who said something stupid like:\n>\n>        echo >&2 \"$(cmd)\"\n>\n> should be equivalent to\n>\n>        cmd >&2\n>\n> which is not the case when output from cmd does not end with a single LF\n> (i.e. either an incomplete line, or with trailing blank lines).\n>\n> Sorry, if that is what you are trying to address, please let me take that\n> back.\n\nYeah, you said:\n\n    >> +  echo >&2 \"$(eval_gettext \"Warning: fetch updated the current\nbranch head.\n    >> +Warning: fast-forwarding your working tree from\n    >> +Warning: commit \\$orig_head.\")\"\n    >\n    > echo \"$(...)\"\n    >\n    > sounds quite wasteful and harder to read than necessary.\n    > The same also happens in later patches.\n\n    A very good point.  Just letting eval_gettext write out to >&2 should be\n    both sufficient and inifinitely more readable.\n\n    -- http://www.spinics.net/lists/git/msg157376.html\n\nWhich is why I rewrote all the relevant patches to look like:\n\n    diff --git a/git-pull.sh b/git-pull.sh\n    index 06dcd81..a10b129 100755\n    --- a/git-pull.sh\n    +++ b/git-pull.sh\n    @@ -217,9 +217,12 @@ then\n            # $orig_head commit, but we are merging into $curr_head.\n            # First update the working tree to match $curr_head.\n\n    -       echo >&2 \"Warning: fetch updated the current branch head.\"\n    -       echo >&2 \"Warning: fast-forwarding your working tree from\"\n    -       echo >&2 \"Warning: commit $orig_head.\"\n    +       (\n    +               eval_gettext \"Warning: fetch updated the current\nbranch head.\n    +Warning: fast-forwarding your working tree from\n    +Warning: commit \\$orig_head.\" &&\n    +               echo\n    +       ) >&2\n            git update-index -q --refresh\n            git read-tree -u -m \"$orig_head\" \"$curr_head\" ||\n                    die \"$(eval_gettext \"Cannot fast-forward your working tree.\n\nI wrote them using echo \"$(gettext \"foo\")\" initially because I thought\nbending over backwards like this was silly.\n\nYou want me to go and change it back now?\n"},{"id":"168017","messageId":"7v62pal5v7.fsf@alter.siamese.dyndns.org","threadId":"27371","inReplyTo":"7vboz2l6h1.fsf@alter.siamese.dyndns.org","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-16T20:58:52Z","receivedAt":"2011-05-16T20:58:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ahh, perhaps I was the one who said something stupid like:\n>\n> \techo >&2 \"$(cmd)\"\n>\n> should be equivalent to\n>\n> \tcmd >&2\n>\n> which is not the case when output from cmd does not end with a single LF\n> (i.e. either an incomplete line, or with trailing blank lines).\n>\n> Sorry, if that is what you are trying to address, please let me take that\n> back.\n\nHaving said that, depending on how the strings are distributed, I have a\nfeeling that we might be better off having two variants:\n\n\tsay >&2 \"<message string>\"\n\tgettext >&2 \"<message string>\"\n\nThe former would be\n\n\tsay () {\n\t\tgettext >&2 \"$1\"; echo\n\t}\n\nand minority of callers (they may be an empty set) that care about\ntrailing blank lines they output can include their own terminating LFs in\nthe message to be translated and call gettext directly, letting it output\nthe translation without stripping trailing LFs they (or their translation)\nproduce.\n"},{"id":"168019","messageId":"BANLkTimuA6-jLAUAMuhVf6FfJ2eNp8ROZw@mail.gmail.com","threadId":"27371","inReplyTo":"7v62pal5v7.fsf@alter.siamese.dyndns.org","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-05-16T21:13:09Z","receivedAt":"2011-05-16T21:13:09Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, May 16, 2011 at 22:58, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Ahh, perhaps I was the one who said something stupid like:\n>>\n>>       echo >&2 \"$(cmd)\"\n>>\n>> should be equivalent to\n>>\n>>       cmd >&2\n>>\n>> which is not the case when output from cmd does not end with a single LF\n>> (i.e. either an incomplete line, or with trailing blank lines).\n>>\n>> Sorry, if that is what you are trying to address, please let me take that\n>> back.\n>\n> Having said that, depending on how the strings are distributed, I have a\n> feeling that we might be better off having two variants:\n>\n>        say >&2 \"<message string>\"\n>        gettext >&2 \"<message string>\"\n>\n> The former would be\n>\n>        say () {\n>                gettext >&2 \"$1\"; echo\n>        }\n>\n> and minority of callers (they may be an empty set) that care about\n> trailing blank lines they output can include their own terminating LFs in\n> the message to be translated and call gettext directly, letting it output\n> the translation without stripping trailing LFs they (or their translation)\n> produce.\n\nThat would require us to start extracting strings from all \"say\"\nfunctions. The reason we have only \"gettext\" and \"eval_gettext\" is so\nxgettext can extract them.\n\nI'd like to keep that simplicity. Let's not go and wrap these\nfunctions for trivial aesthetics at the cost of complexity.\n"},{"id":"168021","messageId":"20110516212641.GB15150@elie","threadId":"27371","inReplyTo":"BANLkTimuA6-jLAUAMuhVf6FfJ2eNp8ROZw@mail.gmail.com","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-05-16T21:26:41Z","receivedAt":"2011-05-16T21:26:41Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n\n> That would require us to start extracting strings from all \"say\"\n> functions. The reason we have only \"gettext\" and \"eval_gettext\" is so\n> xgettext can extract them.\n\nIsn't that what the xgettext -k parameter is for?\n"},{"id":"168022","messageId":"BANLkTi=FLWFzMFG5DgQiaN9kYW3pozJ6HQ@mail.gmail.com","threadId":"27371","inReplyTo":"20110516212641.GB15150@elie","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2011-05-16T21:32:55Z","receivedAt":"2011-05-16T21:32:55Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, May 16, 2011 at 23:26, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Ævar Arnfjörð Bjarmason wrote:\n>\n>> That would require us to start extracting strings from all \"say\"\n>> functions. The reason we have only \"gettext\" and \"eval_gettext\" is so\n>> xgettext can extract them.\n>\n> Isn't that what the xgettext -k parameter is for?\n\nI'm not saying we can't use xgettext to extract these things. I'm\nsaying I don't think it's a good idea.\n\n    $ git --no-pager grep say git-submodule.sh\n    git-submodule.sh:                       say \"$(eval_gettext\n\"Entering '\\$prefix\\$path'\")\"\n    git-submodule.sh:               say \"$(eval_gettext \"Submodule\n'\\$name' (\\$url) registered for path '\\$path'\")\"\n    git-submodule.sh:                       say \"$(eval_gettext\n\"Submodule path '\\$path' not initialized\n    git-submodule.sh:\nsay_msg=\"$(eval_gettext \"Submodule path '\\$path': rebased into\n'\\$sha1'\")\"\n    git-submodule.sh:\nsay_msg=\"$(eval_gettext \"Submodule path '\\$path': merged in\n'\\$sha1'\")\"\n    git-submodule.sh:\nsay_msg=\"$(eval_gettext \"Submodule path '\\$path': checked out\n'\\$sha1'\")\"\n    git-submodule.sh:                       say $say_msg\n    git-submodule.sh:                       say \"U$sha1 $displaypath\"\n    git-submodule.sh:                       say \"-$sha1 $displaypath\"\n    git-submodule.sh:                       say \" $sha1 $displaypath$revname\"\n    git-submodule.sh:                       say \"+$sha1 $displaypath$revname\"\n    git-submodule.sh:               say \"$(eval_gettext \"Synchronizing\nsubmodule url for '\\$name'\")\"\n\nI want to mark *some* of these *manually* as translatable, I don't\nwant to go and extract strings from all invocations to functions like\nprintf & die, instead I want to add a printf(_()) wrapper to\neverything.\n"},{"id":"168023","messageId":"7vvcxajpda.fsf@alter.siamese.dyndns.org","threadId":"27371","inReplyTo":"BANLkTi=FLWFzMFG5DgQiaN9kYW3pozJ6HQ@mail.gmail.com","subject":"Re: Bikeshedding advice on the ab/i18n-scripts series","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-16T21:40:33Z","receivedAt":"2011-05-16T21:40:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Mon, May 16, 2011 at 23:26, Jonathan Nieder <jrnieder@gmail.com> wrote:\n>> Ævar Arnfjörð Bjarmason wrote:\n>>\n>>> That would require us to start extracting strings from all \"say\"\n>>> functions. The reason we have only \"gettext\" and \"eval_gettext\" is so\n>>> xgettext can extract them.\n>>\n>> Isn't that what the xgettext -k parameter is for?\n>\n> I'm not saying we can't use xgettext to extract these things. I'm\n> saying I don't think it's a good idea.\n>\n>     $ git --no-pager grep say git-submodule.sh\n>     git-submodule.sh:                       say \"$(eval_gettext\n> \"Entering '\\$prefix\\$path'\")\"\n\nOh, I didn't mean to say \"we _must_ call that _say_\".\n\nThe discussion suggested to me that we may want two variants, one that\ntakes an incomplete single line and outputs a single complete line, and\nthe other that takes whatever the caller gives and outputs the translated\nlines without further butchering the tail end.  I missed that Jonathan\nalready mentioned gettext_nl and that is fine as well, but if we use a\nfunction other than gettext I thought it would be better to use short and\nsweet name for common cases.\n"}]}