bryceco / GoMap

OpenStreetMap editor for iPhone/iPad
ISC License
323 stars 41 forks source link

Plural forms for translations #742

Closed milotype closed 6 months ago

milotype commented 6 months ago

I´d like to suggest to implement language specific plural forms for all strings with counts/numbers (even if the singular form would never occur). Many languages need more than just one plural form for correct translation. Also, do not use separate strings for plural.one and plural.other (see examples below). The comment "Always plural" also does not help.

Some examples:

#. result of importing GPX routes
#, xml-text
msgctxt ""
"Localizable.xcstrings///%ld new route(s) imported,\n"
"%ld duplicate(s) skipped"
msgid ""
"%1$ld new route(s) imported,\n"
"%2$ld duplicate(s) skipped"
msgstr ""
#. Number of tiles/objects in cache
#, xml-text
msgctxt "Localizable.xcstrings///%ld objects|==|plural.one"
msgid "%ld objects"
msgstr ""
#. Number of tiles/objects in cache
#, xml-text
msgctxt "Localizable.xcstrings///%ld objects|==|plural.other"
msgid "%ld objects"
msgstr ""
#. Always plural
#, xml-text
msgctxt "Localizable.xcstrings///%lu tiles needed"
msgid "%lu tiles needed"
msgstr ""
verhovsky commented 6 months ago

Another issue is that the plural forms many and few don't make it into https://hosted.weblate.org/

bryceco commented 6 months ago

Fixed in 77af29799560f8bc8812662915a3103d4b4bd46f

Another issue is that the plural forms many and few don't make it into https://hosted.weblate.org/

I don't understand what this means, or how to fix it.

verhovsky commented 6 months ago

I also don't know how to fix it, but I'll explain the issue.

The grammatical rule for plurals in English is simple

if count != 1:
    noun += 's'

(not exactly, but you get it). In other languages it's more complicated. In Russian if you want to say "[it took me] x days", each word has 3 plural forms. It goes

1 день 2 дня 3 дня 4 дня 5 дней 6 дней ... 20 дней 21 день 22 дня 23 дня 24 дня 25 дней 26 дней ... 30 дней 31 день 32 дня and so on 10000000021 день

other slavic languages are similar. The rules are given in this table https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html and apple already implements them, you just have to give a translation for each option, which are called one, few, many and other. English just has one → "day" and other → "days" and russian has one → день, few → дня and many → дней, then other is a repeat of few (дня) because other is mandatory. To create a key with a plural you click in Xcode on the translation and click "vary by plural" and give the two forms. But when you then generate the xliff files and upload them to https://hosted.weblate.org/translate/go-map/app/ru/ I only see two forms for russian "one" and "other" but the string should be repeated 4 times with substitutions.<variable name>.plural.one, substitutions.<variable name>.plural.few, substitutions.<variable name>.plural.many and substitutions.<variable name>.plural.other.

Doing the translating in Xcode is actually really nice and straight forward once I understood the syntax.

verhovsky commented 6 months ago

Also, by the way, weblate kind of sucks. Each translatable string is a separate webpage and going to the next string takes 2.5 seconds of just waiting for it to load the page. So if I wanted to edit all 674 strings, that would be like 30 minutes of just waiting for it to load.

Screenshot 2024-04-23 at 16 24 40

https://poeditor.com/ that StreetComplete uses is better. https://app.transifex.com/ too.

Edit: I see now there's "Zen mode" that is a more sensible interface.

bryceco commented 6 months ago

weblate kind of sucks

It's a little painful on the dev side too, but it was recommended early on so I adopted it without looking hard at alternatives.

I assumed that people were are serious about doing translations would use a native app for it, not the web interface, but I have no idea whether that is the case.

1ec5 commented 6 months ago

These days I think translators tend to stick to the online TMSes when they have the choice, except when it comes to especially tricky operations. Sort of like iD versus JOSM – er, iD versus Go Map!! – you know what I mean. 😉 Personally, I haven’t found a TMS with a UI that I particularly love as a translator, but I’m most comfortable in Crowdin, Transifex, and Translatewiki.net. As a developer, I’ve found Crowdin and Transifex to be the most flexible to work with. But that’s just me; everyone has a different opinion, just look at OpenHistoricalMap/issues#268.

bryceco commented 6 months ago

Another issue is that the plural forms many and few don't make it into https://hosted.weblate.org/

Okay, I understand now. In the XLIFF the plural forms are just another string ID, so I don't see why they would get any special treatment by Weblate, or how they are being ignored.

milotype commented 6 months ago

I’m not a developer and I don't know about issues concearning developers using Weblate translation platform.

I’m a translator and I find Weblate a very good platform for translating. Especially usefull at Weblate is the option to export and upload translation files in different file formats.

I often use the option to export the translation file as a .po file, translate it localy with the Poedit app and then upload it back to Weblate.

milotype commented 6 months ago

@bryceco As you agree with my last message, please reopen the issue and solve it. If you can´t do it yourself, maybe you could ask other contributors to help you out … that would be great!

bryceco commented 6 months ago

@bryceco As you agree with my last message, please reopen the issue and solve it. If you can´t do it yourself, maybe you could ask other contributors to help you out … that would be great!

As best I can tell the issue is with Weblate:

So a workaround might be to use a translation app that uses XLIFF 1.2 natively rather than PO.

bryceco commented 6 months ago
Screenshot 2024-04-24 at 1 19 22 PM
milotype commented 6 months ago

@bryceco I´ve translated a lot of apps at "Hosted Weblate" by downloading and uploading .po files without any problems about plural forms.

Maybe you could ask the Weblate author Michal Čihař for help. I have contacted him a couple of times in the past and he allways responded quite quickly.

Some Weblate links where you could file an issue or ask for help:

Just some thoughts … Milo

bryceco commented 6 months ago

Not the first XLIFF bug I've reported to Weblate: https://github.com/WeblateOrg/weblate/issues/11483

bryceco commented 6 months ago

I changed the Weblate configuration to remove "Monolingual base language file" and I'm seeing strings for "few" and "many" now (details in the Weblate bug report above). Please confirm and close this if things look okay.

milotype commented 6 months ago

The translation file looks better and I´ve translated the plural forms in the Croatian translation file. However there are still some issues in strings where plural forms are combined. For instance:

If possible, separate these strings into individual strings with plural forms and combine them later together. I hope you undertand my proposal :-)

Also, I´d suggest not to use the description Note = "Placeholder - do not translate";. For instance for the string Old value: 42 I don´t understand why it should not be translated. ?

bryceco commented 6 months ago

%.0f meters, %ld nodes

This might be a stale string: There's a newer version available with correct plurals but the old string didn't get deleted. I cleaned up a few of them but I'll double check everything.

Regarding the "placeholder" comment: This is a value that gets placed on a label while mocking up the app, but it exists just so the developer can see what the label looks like (font, color, etc). The actual text of the label will be generated at runtime and the mockup value will never be shown.

milotype commented 6 months ago

%.0f meters, %ld nodes

This might be a stale string: There's a newer version available with correct plurals but the old string didn't get deleted. I cleaned up a few of them but I'll double check everything.

OK, let me know when you´re done, and I´ll check the translations.

Regarding the "placeholder" comment: This is a value that gets placed on a label while mocking up the app, but it exists just so the developer can see what the label looks like (font, color, etc). The actual text of the label will be generated at runtime and the mockup value will never be shown.

Sorry, I don´t understand it. I´m not a programmer ... Should strings with Note = "Placeholder - do not translate"; be translated or not?

tordans commented 6 months ago

Should strings with Note = "Placeholder - do not translate"; be translated or not?

Not

bryceco commented 6 months ago

placeholder

It won't hurt if you translate them, but the translation will never be used.

milotype commented 6 months ago

placeholder

It won't hurt if you translate them, but the translation will never be used.

If they don´t need to be translated, I´d suggest to mark those strings as "read-only ", so translators don´t have to waste time translating such strings. Just a thought …

bryceco commented 6 months ago

However there are still some issues in strings where plural forms are combined.

These should now be fixed.

milotype commented 6 months ago

I´m not sure about the following strings. Will those strings use appropriate singular/plural translations?

%1$#@meters@, %2$#@nodes@ %1$#@meters@, %2$#@points@, %3$#@waypoints@

bryceco commented 6 months ago

I'm not an expert but I believe they will, if you translate them and the corresponding components.

verhovsky commented 6 months ago

those two strings should be translated as-is unless your language uses a different comma or something (chinese does for example). the translation of each field like x meters are in 3 separate strings.

bryceco commented 6 months ago

Do not translate strings of the form @meters@ to your local term for meters. Those are names that need to match up with the appropriate substitution strings of the same name.

milotype commented 6 months ago

Just to iterate the issue about "Placeholder" strings which I reported a couple of days ago:

If strings with the description: Note = "Placeholder - do not translate" don´t need to be translated, please mark those strings as "read-only", so translators don´t have to waste time translating such strings. As you explained, … the translation will never be used.

Currently, those strings are still translatable!

bryceco commented 6 months ago

Just to iterate the issue about "Placeholder" strings which I reported a couple of days ago:

@milotype I'm working on this, but it's more complicated than you'd expect. There are 33 such strings spread across 26 languages, so it's not just setting a single flag, or even 33 flags. I just went through the 33 strings and unified the note text to be identical: "Placeholder - Do not translate". I'd like to do a bulk edit in Weblate to set the read-only flag but I haven't figured out how to filter on the note text. Unfortunately there's no easy way to set a read-only flag when the strings are created.

Edit: The magic filter syntax is note:"Placeholder - Do not translate"

Flags should now be set.

milotype commented 6 months ago

It looks good to me ... thank you for your guick implementation :-)