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

Re: [PATCH] i18n: Not add stripped contents for translation

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2012, 06:46 UTC
Message-ID
<7v399mw7k3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CANYiYbHGAG5ijeL3yW5SKYAfMNwtme5ELPeGNPhNyKBPGTONMg@mail.gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 5 quoted lines
>> This is a tangent and I am just showing aloud my ignorance, but I wonder
>> if there is a reasonably generic and "best current practice" way to
>> structure code to show an enumeration in human languages, for example,
> ...
> I write a function for this.

It is not a very good API design to use static array in a function like your code.

You will often want to walk list of lists in a nested loop and want to have two "appends" running in parallel. Imagine you are merging three branches A, B and C in an octopus merge, and want to say "commits A1 and A2 were merged from A". You would want to structure the caller like this:

        clear_list(&list_of_branches);
        # this walks branches A, B and C
        foreach branch
                append_item(&list_of_branches, branch);
                clear_list(&list_of_commits);
                # this walks commits on the branch
                foreach commit on branch
                        append_item(&list_of_commits, commit);
                # this shows e.g. "commits A1 and A2"
                format_list_as_human_string(&list_of_commits);
        # this shows e.g. "branches A, B and C"
        format_list_as_human_string(&list_of_branches);

In any case, I was not asking anybody to come up with an original solution. Rather, I was asking if somebody knew an already widely used library-ish implementation we can just reuse. If there is no such thing, we may end up designing one ourselves, but we shouldn't be doing so if we don't have to.

Previous: Jiang XinNext: Jiang Xin
Message 8 of 10 in “i18n: Not add stripped contents for translation”
  1. i18n: Not add stripped contents for translationJiang Xin, Mar 5, 2012
  2. Junio C HamanoMar 5, 2012
  3. Jiang XinMar 5, 2012
  4. Junio C HamanoMar 5, 2012
  5. Jens LehmannMar 5, 2012
  6. Junio C HamanoMar 5, 2012
  7. Jiang XinMar 6, 2012
  8. Junio C HamanoMar 6, 2012
  9. Jiang XinMar 6, 2012
  10. Jiang XinMar 6, 2012

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.