Giter Club home page Giter Club logo

Comments (5)

gjuchault avatar gjuchault commented on July 25, 2024

Actually, I'll wait on how mashpie will treat your similar issue mashpie#178 to see what to do

from i18n-node-2.

gjuchault avatar gjuchault commented on July 25, 2024

I guess that would be possible by using a function / or a custom object

directory: {
    0: 'There is %n directory',
    1: 'There is %n directory',
    'more': 'Thereis %n directories'
}

A function would be simpler but it can't work in JSON files. Some thoughts @jeresig ?

from i18n-node-2.

gjuchault avatar gjuchault commented on July 25, 2024

New idea : conditions as keys

directory: {
    0: 'There is 0 directory',
    1: 'There is 1 directory',
    '>1': 'There is %n directories'
}

Which would require some sort of eval/parsing. Which is pretty difficult

from i18n-node-2.

pke avatar pke commented on July 25, 2024

well, rails has that solved in its ActiveSupport gem. They have all kind of pluralization with simple rules.

from i18n-node-2.

TiS avatar TiS commented on July 25, 2024

Gettext format solves this by embedding count expression in locale file. The idea is to use empty key in translation file to store some additional information, among them - language rules.

The example of such rules can be seen in test files of another JS translator: https://github.com/messageformat/Jed/blob/master/test/tests.js

I suppose, that upon loading transation file, such rule can be transformed to JS function and then used to fetch appropriate index from different translation forms.

As the gettext format is being widely used on server side and it's proven, maybe this is the way to go.

from i18n-node-2.

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.