Giter VIP home page Giter VIP logo

jsoni18n's People

Contributors

greenkeeper[bot] avatar nicolasroehm avatar rinkattendant6 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nicolasroehm

jsoni18n's Issues

Add support for positional placeholders

It is common to have positional placeholders when localizing due to differences in word order in different languages.

There exists several different formats for positional placeholders. For example:

// ICU format:
'{0, number} files exist on disk {1} at this time'

 // jquery.i18n format:
'$1 files exist on disk $2 at this time'

// PHP printf format
'%1$d files exist on disk %2$s at this time'

Since sprintf and vsprintf are currently being used, the last format already works.

It would be nice to support the jquery.i18n format by parsing the strings and converting the placeholders to printf-style placeholders. However since it does not specify type for its placeholders (string, number, etc.), they would be assumed string by default. A possible improvement would be to look for {{PLURAL to determine if the placeholder could be an integer.

Localization of one-dimensional arrays

The localizeArray function does not allow localization of flat arrays:

{
    "arrayGroups": {
        "bar": {
            "en-CA": "bar_en",
            "fr-CA": "bar_fr"
        }
    }
}
$foo = array(
    'bar_en' => 'good morning',
    'bar_fr' => 'bon matin'
);

$l10n->localizeArray($foo, 'bar', 'fr-CA');

Expected:

$foo = array(
    'bar' => 'bon matin'
);

label tree management

Hi,
is it possible to insert a hierarchy like this?

{ "it-IT": { "greeting": "Ciao %s", "status": { "OPEN": "Aperto", "CLOSED": "Chiuso" } } }

$t->_ef('status.CLOSED');

Invalid key fallback

Is it possible to fallback with the given key instead of showing the Invalid key error ?

Allow addResource to accept PHP arrays and JSON strings

Localization resources may not always come from files and it would be useful to be able to add resources that are in array form (e.g. coming from a database) or in a string of JSON.

This should be easily achieved using json_decode.

Data needs to be validated, perhaps using JSON Schema.

Support __debugInfo method for debugging

PHP 5.6 added a magic method called __debugInfo that returns an array upon calling var_dump on the object. This should be used in place of the debug() method in the classes.

This does not affect compatibility with older PHP versions as the __debugInfo method can be manually called (i.e. $obj->__debugInfo) and var_dump on older PHP versions will return all private, protected, and public variables.

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.