Giter VIP home page Giter VIP logo

Comments (7)

jamuhl avatar jamuhl commented on August 15, 2024 2

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.

eliOcs avatar eliOcs commented on August 15, 2024 1

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.

EFF avatar EFF commented on August 15, 2024 1

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.

jamuhl avatar jamuhl commented on August 15, 2024

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.

eliOcs avatar eliOcs commented on August 15, 2024

I completely misunderstood the plural functionality, but your workaround is perfect. Thanks!

from i18next-node.

jamuhl avatar jamuhl commented on August 15, 2024

glad we found a solution. if you encounter any other issue, just let me know.

from i18next-node.

jamuhl avatar jamuhl commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.