Comments (7)
key_plural_0
would be for a zero based specialform in english - but english has no specialform for 0 (zero uses the regular plural).
i18next supports the plural like in given language and doesn't lookup special cases. You can solve what you try with context http://i18next.com/pages/doc_features.html#context
{
"key_zero": "__count__ like", /* should never be called as zero uses plural form */
"key_zero_plural": "No likes",
"key_many": "__count__ like",
"key_many_plural": "__count__ likes",
}
i18n.t('key', {
count: 0, /* as normal */
context: (count !== 0) ? 'many' : 'zero'
});
from i18next-node.
With this translation .json
{
"key": "__count__ like",
"key_plural": "__count__ likes",
"key_plural_0": "No likes",
"simple": "__count__ like",
"simple_plural": "__count__ likes"
}
The special case for 0 doesn't work. I was expecting:
No likes
1 like
2 likes
Instead of:
0 likes
1 like
2 likes
from i18next-node.
I still can't manage to make plural form work in any language from Jade template.
.text=t("key", {count : 0}) // displays : default
.text=t("key", {count : 1}) // displays : default
.text=t("key", {count : 2}) // displays : default
{
"key" : "default"
"key_zero": "you have no foo"
"key_1_plural": "you have count foo",
"key_plural": "you have count foos",
}
I understand that plural forms are specific to languages but it looks like i still don't understand how it works.
from i18next-node.
english has only singular and plural form -> so you don't need to suffix the keys for en. Only locales with more than one plural form (or zero) need to be suffixed.
from i18next-node.
I completely misunderstood the plural functionality, but your workaround is perfect. Thanks!
from i18next-node.
glad we found a solution. if you encounter any other issue, just let me know.
from i18next-node.
looks strange to me:
// having
{
"key" : "default"
"key_plural": "you have __count__ foos",
}
// it should
.text=t("key", {count : 0}) // should displays : you have 0 foos
.text=t("key", {count : 1}) // displays : default (this one is ok)
.text=t("key", {count : 2}) // should displays : you have 2 foos
the key_zero
and key_1_plural
will only be accessed if you use the respecting keys (key_zero, key_1) or add the context option ( context = zero, context = 1).
when i run the tests in the client repository https://github.com/jamuhl/i18next/blob/master/spec/translate/translate.plurals.spec.js it works correctly...wondering where the problem with 0 and 2 comes from
from i18next-node.
Related Issues (20)
- i18next multiple json packages HOT 2
- Multiple handler on addRoute function HOT 3
- remoteSync don't write empty resource to store if remote is unavaiable
- Semvar violations HOT 2
- How to use variables with handlebars HOT 10
- remoteSync: saveMissing use resSetPath, not resPostPath HOT 3
- document webtranslate path options HOT 1
- document t helper
- Cannot read property '_translationTable' of undefined - i18next on OSX and docker HOT 2
- MongoDB backend fails to initialize HOT 6
- How do I create custom detectLanguage function\middleware? HOT 2
- Error when trying to pluralise HOT 4
- Dynamic routes render on any URL HOT 11
- Dinamically add new namespace? HOT 2
- Question: what is the best practice for i18next-node locales? HOT 9
- [same project?] Some pages down HOT 2
- README clarification HOT 1
- t is not a function HOT 8
- saveMissingTo: "all" does not save missing translation in all languages files
- Dynamic update app language in React Native using i18next HOT 3
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 i18next-node.