"Plural-Forms: nplurals=2; plural=(n>1);\\n" msgid "Wrong password" msgstr "Mot de passe incorrect" msgid "Wrong number" msgid_plural "Wrong numbers" msgstr[0] "Mauvais chiffre" msgstr[1] "Mauvais chiffres"'; $iWrote = file_put_contents($sPoFilename, $sPoContents); $iWrote === false and burn('UnexpectedValueException', sprintf(_WT('Cannot write the file %s.'), $sPoFilename)); exec(sprintf('msgfmt -o %s %s', $sMoFilename, $sPoFilename)); if (!is_file($sMoFilename)) { $this->skip(); } $o = new weeGetTextDictionary($sMoFilename); // weeGetTextDictionary::getHeaders $this->isEqual($aHeaders, $o->getHeaders(), _WT('weeGetTextDictionary::getHeaders does not return the expected headers.')); // weeGetTextDictionary::getCharset $this->isEqual('UTF-8', $o->getCharset(), _WT('weeGetTextDictionary::getCharset does not return the expected charset.')); // weeGetTextDictionary::getTranslation $this->isEqual('Mot de passe incorrect', $o->getTranslation('Wrong password'), _WT('weeGetTextDictionary::getTranslation does not return the expected translation.')); $this->isEqual('foobar', $o->getTranslation('foobar'), _WT('weeGetTextDictionary::getTranslation does not return the expected native sentence when there is no translation available.')); // weeGetTextDictionary::getPluralTranslation $this->isEqual('Mauvais chiffres', $o->getPluralTranslation('Wrong number', 'Wrong numbers', 0), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected translation when n is %d.'), 0)); $this->isEqual('Mauvais chiffre', $o->getPluralTranslation('Wrong number', 'Wrong numbers', 1), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected translation when n is %d.'), 1)); $this->isEqual('Mauvais chiffres', $o->getPluralTranslation('Wrong number', 'Wrong numbers', 2), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected plural translation when n is %d.'), 2)); $this->isEqual('Mauvais chiffres', $o->getPluralTranslation('Wrong number', 'Wrong numbers', 10), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected plural translation when n is %d.'), 10)); $this->isEqual('pouet', $o->getPluralTranslation('pouet', 'Wrong numbers', 0), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected native sentence when n is %d and there is no translation available.'), 0)); $this->isEqual('pouet', $o->getPluralTranslation('pouet', 'Wrong numbers', 1), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected native sentence when n is %d and there is no translation available.'), 1)); $this->isEqual('Wrong numbers', $o->getPluralTranslation('pouet', 'Wrong numbers', 2), sprintf(_WT('weeGetTextDictionary::getTranslation does not return the expected plural native sentence when n is %d and there is no translation available.'), 2));
/** Translate the given string in the current locale using the framework's domain (wee). This function do both gettext and ngettext depending on the number of arguments given. This function is reserved for internal use. @overload _WT($sText) Translate the given text. @overload _WT($sText, $sPlural, $iCount) Plural version of text translation. @return string The translated text. */ function _WT() { static $sLocale = 'C'; static $oDictionary; $sCurrentLocale = setlocale(LC_MESSAGES, 0); if ($sLocale != $sCurrentLocale) { $sLocale = $sCurrentLocale; $oDictionary = null; if ($sLocale != 'C') { $a = explode('.', $sLocale, 2); $sFile = ROOT_PATH . 'share/locale/' . $a[0] . '/LC_MESSAGES/wee.mo'; if (file_exists($sFile)) { $oDictionary = new weeGetTextDictionary($sFile); } } } $aArgs = func_get_args(); $iCount = count($aArgs); if ($iCount == 1) { return $oDictionary !== null ? $oDictionary->getTranslation($aArgs[0]) : $aArgs[0]; } $iCount == 3 or burn('InvalidArgumentException', sprintf(_WT('The %s function requires either 1 or 3 arguments.'), '_WT')); if ($oDictionary !== null) { return $oDictionary->getPluralTranslation($aArgs[0], $aArgs[1], $aArgs[2]); } return $aArgs[2] > 1 ? $aArgs[1] : $aArgs[0]; }