A stand alone i18n php library.
I18n is a php framework agnostic package to handle I18n functionality (such an original name). The goal is to have the ability to implement multiple languages into a website with out needing to depend on a framework.
You can find many examples of how to use the package and any of its parts (which you will most likely never touch) in the tests directory. The tests are done using PHPUnit and are very small, a few lines each, and are a great place to start. Given that, I'll still be showing examples of how the package is intended to work. The following example is a very simplistic usage of the package, good place to start.
use I18n\I18n; $i18n = new I18n; $i18n->set([ 'foo' => 'bar', 'baz' => [ 'rawr' => 'meow?', ], ], 'en_CA'); $i18n->load('en_CA'); echo $i18n->get('baz.rawr'); // will output 'meow?'
You may also set a directory to look at to load the given locales.
use I18n\I18n; $i18n = new I18n; $i18n->load($pathToLocaleDirectory); $i18n->load($locale);
We also support a static facade so you don't need to carry around the I18n object to every part of your application.
use I18n\Facade\StaticI18n; StaticI18n::mount(); I18n::set([ 'foo' => 'bar', 'baz' => [ 'rawr' => 'meow?', ], ], 'en_CA'); I18n::load('en_CA'); echo I18n::get('baz.rawr');