From bd0b183f212d6dd8773f826898327a4b4e8dbbd1 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Fri, 21 Apr 2017 23:08:13 -0400 Subject: [PATCH 1/3] Translating: Describe pluralization (a gotcha) This rough chunk of addition should be enough to fix what #124 is mostly about. --- Contributing-to-Mastodon/Translating.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Contributing-to-Mastodon/Translating.md b/Contributing-to-Mastodon/Translating.md index 63008911..98327156 100644 --- a/Contributing-to-Mastodon/Translating.md +++ b/Contributing-to-Mastodon/Translating.md @@ -46,3 +46,25 @@ Once the pull request is accepted, wait for the code to be deployed on a Mastodo ## Updating the translation Keep an eye on the original English files in `app/assets/javascripts/components/locales` and `config/locales`. When they are updated, pass on the changes to your language files. For new strings, add the new lines to the same position and translate them. Once you’re finished with the updates, you can submit a new pull request. + +## Appendix A. Plural handling + +Different languages use different plural forms to be taken care of by Mastodon. + +For JavaScipt (`.jsx`) translations, this is done in [react-intl](https://github.com/yahoo/react-intl) way, by doing: + +``` +Here {appleCount, plural, one {is an apple} other {are {appleCount} apples}}. +``` + +On the other hand, `.yml` files are processed by [rails-i18n](https://github.com/svenfuchs/rails-i18n). Items that look like this are pluralized fields: + +```YML +eat_apple: + one: You ate an apple. + other: You ate %{count} apples. +``` + +In both cases you can see a `one` case and an `other` case described for the pluralized strings. The exact strings is chosen by how many a certain quantity is -- when there is exactly one of something, the sentence goes to the `one` case; otherwise it goes to the `other` case. This is the case for English (`en`) and a few other languages. + +There are, however, many languages that don't operate in the one-other way. Polish as four plural forms, named `one`, `few`, `many`, and `other` respectively. Arabic has six. Chinese, Japanese, and Korean only have one form called `other`. If your language does not operate in the one-other way, be sure to check out the cardinal part of this [Unicode CIDR Plural Rules](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html) chart. From 388c5037e9d80f8594882ab646eabedda5bc6fea Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Fri, 21 Apr 2017 23:11:40 -0400 Subject: [PATCH 2/3] fixup obvious mistakes (squash this commit) --- Contributing-to-Mastodon/Translating.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Contributing-to-Mastodon/Translating.md b/Contributing-to-Mastodon/Translating.md index 98327156..b4f261a7 100644 --- a/Contributing-to-Mastodon/Translating.md +++ b/Contributing-to-Mastodon/Translating.md @@ -51,7 +51,7 @@ Keep an eye on the original English files in `app/assets/javascripts/components/ Different languages use different plural forms to be taken care of by Mastodon. -For JavaScipt (`.jsx`) translations, this is done in [react-intl](https://github.com/yahoo/react-intl) way, by doing: +For JavaScipt (`.jsx`) translations, this is done in [react-intl](https://github.com/yahoo/react-intl), by doing: ``` Here {appleCount, plural, one {is an apple} other {are {appleCount} apples}}. @@ -65,6 +65,6 @@ eat_apple: other: You ate %{count} apples. ``` -In both cases you can see a `one` case and an `other` case described for the pluralized strings. The exact strings is chosen by how many a certain quantity is -- when there is exactly one of something, the sentence goes to the `one` case; otherwise it goes to the `other` case. This is the case for English (`en`) and a few other languages. +In both examples you can see a `one` case and an `other` case described for the pluralized strings. The exact strings is chosen by how many a certain quantity is -- when there is exactly one of something, the sentence goes to the `one` case; otherwise it goes to the `other` case. This how plualization works for English (`en`) and a few other languages. There are, however, many languages that don't operate in the one-other way. Polish as four plural forms, named `one`, `few`, `many`, and `other` respectively. Arabic has six. Chinese, Japanese, and Korean only have one form called `other`. If your language does not operate in the one-other way, be sure to check out the cardinal part of this [Unicode CIDR Plural Rules](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html) chart. From c1d1431c02155b856035948a424404b0ed7f5568 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Fri, 21 Apr 2017 23:16:50 -0400 Subject: [PATCH 3/3] fixup minor (squash this) --- Contributing-to-Mastodon/Translating.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contributing-to-Mastodon/Translating.md b/Contributing-to-Mastodon/Translating.md index b4f261a7..9e520127 100644 --- a/Contributing-to-Mastodon/Translating.md +++ b/Contributing-to-Mastodon/Translating.md @@ -67,4 +67,4 @@ eat_apple: In both examples you can see a `one` case and an `other` case described for the pluralized strings. The exact strings is chosen by how many a certain quantity is -- when there is exactly one of something, the sentence goes to the `one` case; otherwise it goes to the `other` case. This how plualization works for English (`en`) and a few other languages. -There are, however, many languages that don't operate in the one-other way. Polish as four plural forms, named `one`, `few`, `many`, and `other` respectively. Arabic has six. Chinese, Japanese, and Korean only have one form called `other`. If your language does not operate in the one-other way, be sure to check out the cardinal part of this [Unicode CIDR Plural Rules](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html) chart. +There are, however, many languages that don't operate in the one-other way. Polish as four plural forms, named `one`, `few`, `many`, and `other` respectively. Arabic has six. Chinese, Japanese, and Korean only have one form called `other`. If your language does not use one/other plural forms, be sure to check out the cardinal part of this [Unicode CIDR Plural Rules](http://www.unicode.org/cldr/charts/28/supplemental/language_plural_rules.html) chart. Also as a rule of thumb, always start translaing with the `other` case in the English files as they are better generalized than the `one` case.