{ return $this->key; } function getTitle() { return $this->title; } function load() { require __DIR__ . "/../locale/" . $this->key . ".php"; return $result; } } $locales = array('de' => 'German', 'fr' => 'French', 'jp' => 'Japanese', 'ru' => 'Russian', 'zh' => 'Chinese'); foreach ($locales as $locale => $title) { I18n::addAvailableLocale(new GenericLocale($locale, $title)); } I18n::addDefaultKeys(array(':site_name' => get_site_config('site_name'))); // set locale as necessary if (isset($_COOKIE["locale"]) && in_array($_COOKIE["locale"], array_keys(I18n::getAvailableLocales()))) { I18n::setLocale($_COOKIE["locale"]); } \Openclerk\Events::on('i18n_missing_string', function ($data) { $locale = $data['locale']; $key = $data['key']; log_uncaught_exception(new LocaleException("Locale '{$locale}': Missing key '{$key}'")); }); /** * Helper function to mark strings that need to be translated on the client-side. */ function ct($s)
function setUp() { I18n::addAvailableLocale(new TestFrenchLocale()); I18n::setLocale('fr'); }