Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plural forms for a languages like ZH, KO, or JA #34

Closed
nilcolor opened this issue Mar 2, 2020 · 8 comments
Closed

Plural forms for a languages like ZH, KO, or JA #34

nilcolor opened this issue Mar 2, 2020 · 8 comments

Comments

@nilcolor
Copy link

nilcolor commented Mar 2, 2020

Let say we have these strings we need to translate to a language without plural form. For Example Korean.

Wat|Got %{count} bonus -> %{count} 보너스를 받았습니다
Wat|Got %{count} bonuses -> %{count} 보너스를 받았습니다

When locize download --format po is called, we've got this for KO language

msgid ""
msgstr ""
"Project-Id-Version: locize\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0\n"
"Language: ko\n"

msgid "Wat|Got %{count} bonus|#|Wat|Got %{count} bonuses"
msgstr "%{count} 보너스를 받았습니다"

Which obviously do not allow translation to be found.

λ locize --version
7.0.3

Is it possible to use _plural for strings like these anyway?

msgid "Wat|Got %{count} bonus"
msgid_plural "Wat|Got %{count} bonuses"
msgstr[0] "%{count} 보너스를 받았습니다"
msgstr[1] "%{count} 보너스를 받았습니다"

Not sure this is the correct but cannot find a better solution.

@adrai
Copy link
Collaborator

adrai commented Mar 2, 2020

I don't know exactly what you want to achieve...
Are you using the i18next format?
If so, can you try how it looks like when you use locize download --format po_i18next? Is there any difference?
To assist you further, it would be nice to know your projectId. (you can also send an email to support@locize.com)

@nilcolor
Copy link
Author

nilcolor commented Mar 2, 2020

I don't know exactly what you want to achieve...

Maybe something like in the last example... msgid "Wat|Got %{count} bonus|#|Wat|Got %{count} bonuses" doesn't looks like a correct ID for a string. I'll check with po_i18next format.

@nilcolor
Copy link
Author

nilcolor commented Mar 2, 2020

If so, can you try how it looks like when you use locize download --format po_i18next? Is there any difference?

--format po_i18next gives the same result.
Also, Locize UI show 2 rows (singular and plural forms) for all languages except JA, KO, ZH.

P.S. If possible, I'll share projectid later.

@adrai
Copy link
Collaborator

adrai commented Mar 2, 2020

hmm...
May I ask which i18n lib you are using?
If you like we can continue also via mail, because this seems not to be directly related to the cli.

@nilcolor
Copy link
Author

nilcolor commented Mar 2, 2020

This is kinda follow-up for this issue #30
We are using https://github.com/grosser/fast_gettext to work with PO files.
They are downloaded from Locize via

locize download --project-id $LOCIZE_PROJECT_ID --ver latest --language ko --format po

Other languages like FR/IT/etc looks fine.
But those, with "Plural-Forms: nplurals=1; plural=0\n" are not working with plurals.

@adrai
Copy link
Collaborator

adrai commented Mar 2, 2020

ok, can you try to save or rename the keys (in your reference language) in locize ui like this:
i.e. in your reference language:

{
  "Wat|Got %{count} bonus|#|Wat|Got %{count} bonuses_plural": "Wat|Got %{count} bonuses",
  "Wat|Got %{count} bonus|#|Wat|Got %{count} bonuses": "Wat|Got %{count} bonus"
}

image

i.e. in zh

{
  "Wat|Got %{count} bonus|#|Wat|Got %{count} bonuses_plural": "Wat | Got%{count}奖金",
  "Wat|Got %{count} bonus|#|Wat|Got %{count} bonuses": "Wat | Got%{count}奖金"
}

image

You need to have both keys.

after locize download --format po the po files should look like this:

msgid ""
msgstr ""
"Project-Id-Version: locize\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2020-03-02T12:55:52.000Z\n"
"PO-Revision-Date: 2020-03-02T12:55:52.000Z\n"
"Language: en\n"

msgid "Wat|Got %{count} bonus"
msgid_plural "Wat|Got %{count} bonuses"
msgstr[0] "Wat|Got %{count} bonus"
msgstr[1] "Wat|Got %{count} bonuses"

and this in zh:

msgid ""
msgstr ""
"Project-Id-Version: locize\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0\n"
"POT-Creation-Date: 2020-03-02T12:56:13.000Z\n"
"PO-Revision-Date: 2020-03-02T12:56:13.000Z\n"
"Language: zh-cn\n"

msgid "Wat|Got %{count} bonus"
msgid_plural "Wat|Got %{count} bonuses"
msgstr[0] "Wat | Got%{count}奖金"
msgstr[1] "Wat | Got%{count}奖金"

@nilcolor
Copy link
Author

nilcolor commented Mar 3, 2020

So... "Add plural(s)" option from Locize is not working as expected? (8MB gif below, sorry)

plurals_640

@adrai your idea means to not use plurals but something special, correct? Also, this may (or will?) affect the way we sync data between Locize and local development. When plural keys collected locally, they synced exactly as shown on the attached gif.

@adrai
Copy link
Collaborator

adrai commented Mar 3, 2020

If you use locize sync with po format the keys should be "generated" in locize automatically and your po files should look correct.
About the "Add plurals" button, this depends on your choosen i18n format. Seems you have selected "i18next", but you should choose "other".
The "Add plurals" button is an additional feature for the i18next format, so this is why it will produce "wrong" keys for you.

To summarize: I would suggest to:

  • change your i18n format to "other"
  • use locize sync to syncronize your po files

@adrai adrai closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants