/**
  * @test
  */
 public function shouldUseUnderscoreWithTwoArgsFunction()
 {
     // given
     $i18n = I18N::instance();
     $i18n->setPath($this->getTestResourcePath('langs'));
     $i18n->setDefaultLang('en');
     $_GET['lang'] = 'fr';
     $_SESSION['lang'] = 'fr';
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr';
     // when
     $yellow = \__('Generic', 'YELLOW');
     // then
     $this->assertEquals('en Yellow', $yellow);
 }
Example #2
0
 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt
 *
 * Authors of STUdS (initial project): Guilhem BORGHESI (borghesi@unistra.fr) and Raphaël DROZ
 * Authors of Framadate/OpenSondate: Framasoft (https://github.com/framasoft)
 *
 * =============================
 *
 * Ce logiciel est régi par la licence CeCILL-B. Si une copie de cette licence
 * ne se trouve pas avec ce fichier vous pouvez l'obtenir sur
 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.txt
 *
 * Auteurs de STUdS (projet initial) : Guilhem BORGHESI (borghesi@unistra.fr) et Raphaël DROZ
 * Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
 */
// Prepare I18N instance
$i18n = \o80\i18n\I18N::instance();
$i18n->setDefaultLang(DEFAULT_LANGUAGE);
$i18n->setPath(__DIR__ . '/../../locale');
// Change langauge when user asked for it
if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES))) {
    $_SESSION['lang'] = $_POST['lang'];
}
/* <html lang="$locale"> */
$i18n->get('', 'Something, just to load the dictionary');
$locale = $i18n->getLoadedLang();
/* Date Format */
$date_format['txt_full'] = __('Date', 'FULL');
//summary in create_date_poll.php and removal date in choix_(date|autre).php
$date_format['txt_short'] = __('Date', 'SHORT');
// radio title
$date_format['txt_day'] = __('Date', 'DAY');
Example #3
0
/**
 * This method is a shortcut to <code>I18N::instance()-&gt;get($key);</code>.
 *
 * Examples:
 * <ul>
 *  <li>__('SimpleKey')</li>
 *  <li>__('Generic', 'Yes')</li>
 * </ul>
 *
 * @param string $sectionOkKey The Section of the translation (ex: 'Generic'), or the key if no section is used
 * @param string $key The key of the translation (the first arguments must be the name of the Section)
 * @return string The translation
 */
function __($sectionOkKey, $key = null)
{
    return I18N::instance()->get($sectionOkKey, $key);
}
Example #4
0
 /**
  * @test
  * @dataProvider useLangFromGETProvider
  */
 public function shouldNotLookInto_GET($useLangFromGET, $expected)
 {
     // given
     $i18n = new I18N();
     $i18n->setDefaultLang('en');
     $_GET['lang'] = 'fr';
     // stub
     // when
     $i18n->useLangFromGET($useLangFromGET);
     $langs = $i18n->getAvailableLangs();
     // then
     $this->assertEquals($expected, $langs);
 }