-
Notifications
You must be signed in to change notification settings - Fork 64
Description
I came across a few cases where the pot exporter didn't have the functionality that I needed. I'm going to try to implement it myself, even though I'm not yet sure that it's technically possible to implement all the things listed below, because I haven't researched it yet.
Still, before I proceed, I'd like to lay it all out in the open, so it can be discussed and altered if necessary.
Proposal 1
Right now it's unclear how to proceed if one word in English has two different translations based on context.
First of all, there will be no context at all, after the #100 issue is fixed.
And second, even while we still have it, the exporter ignores the same words.
Tentative proposal to solve this is to add the following command line options:
--add-comments[=keyword]
--add-context[=keyword]
If the gathered string is directly preceded by commented out lines in dart, we'll check if they begin with translator or context keywords. By default, it should look like:
// translator: ...// context: ...Same words with different context should be exported separately.
The keywords can be altered in the command line.
This would also fix #95
Proposal 2
"Mobs: %s".plural(length).fill([length]) currently exports the following:
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgid "Mob: %s"
msgid_plural "Mob: %s"
msgstr[0] ""
While what it should be able to export is this:
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgid "Mob: %s"
msgid_plural "Mobs: %s"
msgstr[0] ""
POEdit supports plurals, but whatever is gathered is set in stone and the English plural form can't be changed, so it has to be set in the code. In POEdit it looks like this when the exports are manually corrected:
Importing this back works correctly with other locales, but the English version keeps displaying "Mob" and not "Mobs". I'm assuming it's a bug?
Proposed syntax:
"Mob: %s".plural("Mobs: %s", length)
This would fix the problem if you're translating from English.
(Obviously, if we're developping the software in a language other than English and which has different plural forms, we'll eventually need to be able to define these plural forms immediately in the code. But my suggestion for now is to make English-to-anything localizations work at least. Anything-to-anything can be taken care of later.)
Proposal 3
Gender is not supported for export. POT doesn't support genders, but we can make do. Most languages have from two to four genders, e.g. masculine, feminine, neuter and plural.
My proposal is to add a .gender() suffix, and if it's encountered, then the string gets exported as many times as there are genders, and the gender is prepended to the context.
The amount of genders (and their names) can be defined in a command line parameter as follows: --genders[=gen1,gen2]
Default values are [masculine, feminine]
This means that we need to be able to define English genders in the code, too.
My proposal is to use the first one as default, and the other ones are specified as parameters by order of appearance.
Example 1:
"He's doing his job".gender("She's doing her job", "They're doing their job", genderIndex)With the --genders=masculine,feminine,plural, it would produce:
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgctxt: masculine
msgid "He's doing his job"
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgctxt: feminine
msgid "She's doing her job"
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgctxt: neuter
msgid "They're doing their job"
Example 2:
"strong".gender()This would produce same text in English 3 times, but it allows us to localize it differently in languages where the adjectives are conjugated based on gender.
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgctxt: masculine
msgid "strong"
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgctxt: feminine
msgid "strong"
#: ./lib\peace_screen_widgets\mob_widgets.dart:33
msgctxt: neuter
msgid "strong"
Let me know what you think.
