rinkattendant6 / jsoni18n Goto Github PK
View Code? Open in Web Editor NEWSimple PHP internationalization library using JSON data
License: Mozilla Public License 2.0
Simple PHP internationalization library using JSON data
License: Mozilla Public License 2.0
JsonI18n should stop attempting to add the resource when malformed JSON is encountered.
This can be checked with json_last_error()
.
When null
is passed as the first parameter to localizeArray()
, a catchable fatal error is thrown due to the type hinting.
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.
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'
);
Hi,
is it possible to insert a hierarchy like this?
{ "it-IT": { "greeting": "Ciao %s", "status": { "OPEN": "Aperto", "CLOSED": "Chiuso" } } }
$t->_ef('status.CLOSED');
Is it possible to fallback with the given key instead of showing the Invalid key
error ?
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.