/** * Like previous function, but with i18n support. * It's allow to serve static content build with the template engine. * The first variable part of the url must be the language code. * /[en|fr|de]/home * /[en|fr|de]/contacts */ public function simpleWithLocale($request, $match, $template) { Translation::setLocale(strtolower($match[1])); return shortcuts\Template::RenderToResponse($template, array(), $request); }
public function testSetLocale() { $locales = shell_exec('locale -a'); if (false === strpos($locales, 'fr_FR')) { $this->markTestSkipped('fr_FR locale not available.'); return; } $current = setlocale(LC_CTYPE, 0); Translation::setLocale('fr'); $new = setlocale(LC_CTYPE, 0); $this->assertEquals('fr_FR.UTF-8', $new); Translation::setLocale($current); $new = setlocale(LC_CTYPE, 0); $this->assertEquals($current, $new); }