Topic: Preparing for translation
kaputtnik Topic Opener |
Posted at: 2023-12-29, 13:10
Some questions about preparing for translation: npgettext, example:
Do the arguments to npgettext also need the translation function What about such a construct (total_gr, granite and marble are numbers):
Will it be sufficient to add a translators comment with an example of the resulting text? Or should each row be a separate translation string? I have also a function that turns a fields table to a string:
Does this need special treating because of the numbers? E.g. using bformat? Top Quote |
Nordfriese |
Posted at: 2023-12-29, 15:35
No, ngettext already is the translation function. Translating the arguments again will not work. Note that string concatenation for translatable texts will lead to grammar errors in languages with a different syntax. Just use one very long ngettext call with the complete text, e.g.
Also note that we don't usually use ngettext at all just to distinguish singular and plural (and just add a TRANSLATORS comment to let us know if someone needs plural forms), and only use ngettext if the actual number is part of the text.
Again, please no string concatenations, instead use something like
If a translatable string contains leading or trailing whitespace, you're always doing something wrong.
Again, yes, use When in doubt, always prefer Top Quote |
kaputtnik Topic Opener |
Posted at: 2023-12-29, 15:52
Many thanks! Is this snipped correct?
Top Quote |
Nordfriese |
Posted at: 2023-12-29, 19:39
No,
Top Quote |
kaputtnik Topic Opener |
Posted at: 2023-12-30, 10:06
Thanks again! Hopefully i applied most of those preparations now. There are two places where some more text is shown. According to the documentation (Handling long strings) they should be split into shorter parts. For one i did this:
I think for the second place of long text splitting is not needed?
Last question: Do translators need to know if a string is shown as a header? For the header of table columns i added a translators comment, but for other strings i am not sure. Top Quote |
Nordfriese |
Posted at: 2023-12-30, 12:57
Yes those examples look right. Splitting for long strings is only necessary for reeeaaaally long texts, as in hundreds of words, and then the real point is that such a text should be better split into several paragraphs; Transifex offers fuzzy string matching so a small change in a long text does not force the translator to type the entire text again. Whether a text is used as a header is usually not relevant, but adding TRANSLATORS comments to explain how and where a string is used can never hurt Top Quote |
kaputtnik Topic Opener |
Posted at: 2024-01-20, 12:20
I have a string (tool tip) which is defined for three editboxes: "Enter coordinates in form of x, y" I do not know if all three strings appear on transifex, although they are equal and one translation would fit. Do a translator has to translate the same string three times? Is it better to define this string only one time? E.g. make one variable out of it and use this variable for the three editboxes? Top Quote |
Nordfriese |
Posted at: 2024-01-20, 14:53
Identical strings only appear once on Transifex, unless you explicitly disambiguate them with For long strings that are used many times, a variable can still be useful to keep consistency if you ever want to change the phrasing or spelling, but for such a short string used in only 3 places this is not a concern and would IMHO only make the code less readable. Top Quote |
kaputtnik Topic Opener |
Posted at: 2024-10-14, 15:55
Another question: I have a function that turns milliseconds to hh:mm:ss and returns the fomatted string:
When using this returned string, i guess this needs no translation anymore, but i am not sure. E.g.:
Top Quote |
Nordfriese |
Posted at: 2024-10-14, 18:18
It is quite superfluous, although it does no harm.
P.S. Edited: 2024-10-14, 18:19
Top Quote |