dev-master
9999999-dev https://github.com/biniweb/php-i18nSimple Component for internationalizing
MIT
The Requires
- php >=5.4
- mustache/mustache v2.5.1
- simplon/helper 0.6.*
by Giuseppe Maniscalco
i18n
Simple Component for internationalizing
Simple PHP i18n, (*1)
Some of its features:, (*2)
To use the i18n class, look at the test/example.php or test/example_mustache.php and test/example_mustache.html. You will find there a simple tutorial for this class in the file. Otherwise follow these easy five steps:, (*3)
To use this class, you have to use ini files for the translated strings. This could look like this:, (*4)
en.ini
(English), (*5)
greeting = "Hello World!" [category] somethingother = "Something other..."
de.ini
(German), (*6)
greeting = "Hallo Welt!" [category] somethingother = "Etwas anderes..."
example.php
, (*7)
$data = [ 'file_path' => 'languages/{LANGUAGE}.ini', ]; $configVo = new \Biniweb\I18n\Vo\I18nConfigVo($data); $l = \Biniweb\I18n\I18n::getInstance()->init($configVo);
example.php
, (*8)
<p>A greeting: <?php echo $l['greeting']; ?> </p> <p>Something other: <?php echo $l['category_somethingother']; ?> </p>
example_mustache.php
, (*9)
$data = [ 'file_path' => 'languages/{LANGUAGE}.ini', ]; $configVo = new \Biniweb\I18n\Vo\I18nConfigVo($data); $l = \Biniweb\I18n\I18n::getInstance()->init($configVo); $content = join('', file('example_mustache.html')); $engine = new Mustache_Engine(); echo $engine->render($content, [ 'l' => $l, ]);
example_mustache.html
, (*10)
<p>A greeting: {{#l}} {{greeting}} {{/l}}</p> <p>Something other: {{#l}} {{category_somethingother}} {{/l}}</p>
Simple Component for internationalizing
MIT
i18n