Comments (2)
It's funny that in compiled .untranslated.json files I also get completely different results:
// en-us.untranslated.json
[
{
"id": "sample_test",
"translation": {
"one": "{{.Type}} by {{.Owner}}",
"other": "{{.Type}} by {{.Owner}}"
}
}
]
// ru-ru.untranslated.json
[
{
"id": "sample_test",
"translation": {
"few": "{{.Type}} by {{.Owner}}",
"many": "{{.Type}} by {{.Owner}}",
"one": "{{.Type}} by {{.Owner}}",
"other": "{{.Type}} ΠΎΡ {{.Owner}}"
}
}
]
from go-i18n.
There are a couple things you need to understand about pluralization in languages.
1) zero != 0
You can't assume that plural categories like zero, one, two map to specific numbers like 0, 1, 2. In some languages the "two" category might be used for any number that ends in the number 2 (e.g. 2, 12, 22, etc.).
If you want to have special logic for specific numbers like 0, 1, 2, then you need to write code and have different translations for each of these cases.
// gross pseudocode
if x == 0 {
t("no_apples")
} else {
t("some_apples", x)
}
2) Plural categories depend on the language
English has two plural categories: one ("I have 1 apple") and other ("I have 0 apples", "I have 2 apples", etc.). There is no zero category in English because the pluralization for zero is not special.
Russian has four categories: few, many, one, other (and does not have a zero category). You need to provide a translation for all of the four categories unless you are ok with saying the equivalent of "I have 1 apples".
The goi18n tool understands which pluralizations belong to which languages, so it will drop useless pluralizations (e.g. zero in English, and zero in Russian) and add pluralizations that you need to translate (e.g. few, many, one, other in Russian).
The .untranslated.json
file is what you send to translators to translate so it include all keys with either the known translation or the source English translation. Since Russian has a few category and English does not, it defaults to copying over the other source string from English. It is up to the translator to decide what translation make sense.
I hope this clarifies some things for you. From what I can tell, all of the behavior that you have observed is expected.
from go-i18n.
Related Issues (20)
- Is there are way to properly handle translation based on gender HOT 1
- Error handling is faulty HOT 3
- Setting the delimiters globally? HOT 2
- How to generate translations for the toml files HOT 3
- Upgrade golang.org/x/text v0.3.8 HOT 1
- `goi18n extract` doesn't seem to work for source file that use generics HOT 3
- Cound you export this function or when translation has error get the original value HOT 7
- Hook to commonly catch errors HOT 4
- Just a review
- Easy wrapper around this library HOT 1
- List fitting problem HOT 3
- merging new translation into existing translations omits the hashes
- [Question] Is there any way for reverse lookup in bundle? HOT 1
- Upgrade golang.org/x/text HOT 1
- Breaks on key description HOT 1
- Expose fields (or add access methods) of MessageNotFoundErr HOT 4
- Support template.Options for setting up missing key behavior HOT 2
- V2 is removed HOT 4
- Can we add support of Tajik (TG) language HOT 3
- error `unsupported file format <nil>` when a yaml value is empty HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-i18n.