Avoid plural forms in non-GUI translatable strings (lacks %n support) #31890

issue hebasto openend this issue on February 17, 2025
  1. hebasto commented at 2:50 pm on February 17, 2025: member

    In non-GUI code, translatable strings with format specifiers rely on the tinyformat::format implementation, which does not support the %n specifier that is crucial for pluralising with Qt translation tools.

    Therefore, it may be worth considering rephrasing translatable strings to avoid potential plural forms.

    This issue was initially reported on Transifex: https://app.transifex.com/bitcoin/bitcoin/translate/#fr/qt-translation-029x/570550303/.

    Here is an example of such a string: https://github.com/bitcoin/bitcoin/blob/db36a92c02b83f2e6477a5a55fc061319f7cc6a3/src/init.cpp#L991

  2. maflcko added the label Brainstorming on Feb 17, 2025
  3. maflcko added the label GUI on Feb 17, 2025
  4. maflcko added the label Utils/log/libs on Feb 17, 2025
  5. laanwj commented at 11:15 am on February 25, 2025: member

    Do we know how %n is implemented? Could this be added to tinyformat? Or does it rely on Qt specific state?

    Edit: no, i don’t think this is possible, it would need the translation engine while formatting.

  6. fanquake commented at 5:49 pm on March 4, 2025: member

    I’m not really sure what we can do here. We could try and change all the strings now, but then it’s whack-a-mole with requirements that developers are not really aware off, nor are enforced by anything (similar thoughts for changes like #31987).

    Here is an example of such a string: “Not enough file descriptors available. %d available, %d required.”

    What would you change the string to in this case? How many strings are there that need changing?

  7. hebasto commented at 6:22 pm on March 4, 2025: member

    What would you change the string to in this case?

    I’ve asked our translators.

  8. fanquake commented at 5:05 pm on July 15, 2025: member
    Was there any followup here?
  9. hebasto commented at 3:22 pm on July 17, 2025: member

    Was there any followup here?

    Below is the response I received:

    Hi, Hennadii

    Here are some pluralization guidelines I wrote for one of my clients. Feel free to share them with the team:

    “Use proper plural forms

    Pluralization (p11n) is the process of changing nouns from the singular to the plural form. Not all languages change plural forms of nouns in the same way, some don’t have any plural form.

    There is a difference between plural forms and plural rules

    Plural forms are changes applied to a noun, an adjective or a verb when the word changes grammatical number. Chinese, Indonesian, Japanese, Korean, Thai and Vietnamese don’t have any plurals, so there is one single form.

    • German, Dutch, English, have two plural forms.

    • French, Italian, Portuguese, Romanian and Spanish have three plural forms.

    • Polish and Russian have four plural forms.

    • Arabic has six plural forms.

    Plural rules will tell you how to “get” the plural form. Sometimes it means adding a simple suffix like “s”, e.g., in English from “file” to “files”. In Russian, we would have: “”, “”, “”, and “”.

    Understanding CLDR (Common Locale Data Repository)

    The Unicode Consortium has created the CLDR project with the aim of tackling different plural forms and rules.

    Once the fixed part of the string is created, then the variable element (placeholder) is included. The CLDR presents a huge amount of data for many languages—including plural forms and rules.

    With CLDR, up to six different plural forms are categorized:

    • zero

    • one (singular)

    • two (dual)

    • few (paucal)

    • many (also used for fractions if they have a separate class)

    • other (required—general plural form—also used if the language only has a single form)

    Transifex supports pluralized strings.

    In English, you may find it natural to use two strings to solve plurals: delete-cookie = Delete cookie delete-cookies = Delete cookies

    Transifex documentation states: Don’t use “1 character” and “# characters” in your code. Include the variable in all cases, i.e., use this: “# character” and “# characters”.

    Why? English uses two plural rules: “one” (“1 character”) and “other” (“0,2,10 characters”). But other languages bundle the different cases in other ways. For example, in Portuguese, it’s “0, 1 character” and “2, 10 characters”. So, when coding, ensure you always include the variable denoting the number of objects in the string.

    Transifex supports only one plural per pluralized strings. %1$d images and %1$d videos can’t be pushed as such.

    There are two solutions: Exceptionally create two separate strings and make one sentence out of the two:

    1. %1$d images

    2. and %1$d videos Create two separate strings and present them differently in the UI: %1$d images | %1$d videos

    3. %1$d images

    4. %1$d videos

    5. The pipe is hardcoded here.”

    For the case at hand, an easy solution is to create two pluralized strings:

    First pluralized string: Single form (one): Not enough file descriptors available. %d available.

    Plural form (other): Not enough file descriptors available. %d available.

    Second pluralized string: Single form (one): %d required.

    Plural form (other): %d required.

    You can then programmatically use both to make one sentence.

    We can see that the singular and plural forms are identical in English, as gender and plural agreement only exist for some languages. For such cases, the string dev notes need to clearly explain how the string is being used, with an example.

    On GitHub, someone mentions Qt. If Bitcoin Core is built with Qt, instead of using the XLIFF file type in Transifex, did you consider using the QT file format that Transifex offers and fully support? Would it make your life easier?

    Kind regards,

    AO French language coordinator | Localization Lab localizationlab.org | transifex.com/organization/otf 5C8F 0C0C 4812 7771 365C 262D 47DC 6187 47A9 22D2

    There seems to be some misunderstanding about how we gather translatable string from the non-GUI code.

  10. maflcko commented at 3:40 pm on July 17, 2025: member

    It seems a bit too much hassle to:

    • Split any format string into multiple, so that transifex can handle the plural forms
    • Implement runtime string-translation on plural strings (would need a manually placed macro/function call)

    Seems fine to just let users figure out the plural form and then “correct the typo” while reading?

  11. hebasto closed this on Jul 17, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-12 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me