protected function _process($sFormat)
 {
     $this->_getInterpretor()->setFormat($sFormat);
     $sLangDetected = $this->_getInterpretor()->detectLanguage($this->_oString->get());
     $sLocaleDetected = Loc::buildFromLang($sLangDetected);
     return $sLocaleDetected;
 }
示例#2
0
 /**
  * Définit la locale courante.
  * 
  * @param string $sLocale Locale.
  * @throws \Exception
  */
 public function setLocale($sLocale)
 {
     if (!is_string($sLocale)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_STRING);
     }
     if (!Locale::isValid($sLocale)) {
         throw ExceptionType::domain("Argument #1 ({$sLocale}) n'est pas une locale valide.", Exception::FROM_STRING);
     }
     $this->_sLocale = $sLocale;
     return $this;
 }
示例#3
0
 public function __construct($sType, $sLocale)
 {
     if (!is_string($sType)) {
         throw ExceptionType::invalidArgument("Argument #1 doit être une chaîne de caractères.", Exception::FROM_LOCALE);
     }
     if (!Locale::isValid($sLocale)) {
         throw ExceptionType::domain("Argument #2 doit n'est pas une locale valide.", Exception::FROM_LOCALE);
     }
     $sLocaleNamespace = 'Aouka\\Text\\Locale\\' . $sLocale . '\\' . ucfirst(strtolower($sType));
     $oLocaleClass = new \ReflectionClass($sLocaleNamespace);
     $oLocaleInstance = $oLocaleClass->newInstance();
     $this->_oLocaleInstance = $oLocaleInstance;
 }
示例#4
0
 /**
  * Définit la langue et la locale de destination.
  * 
  * @param string $sLocaleOrLang Code de locale ou langue de destination.
  */
 protected function _setDestinationLocaleLanguage($sLocaleOrLang)
 {
     // Si le code reçu n'est pas une locale
     if (!preg_match('`_|-`', $sLocaleOrLang)) {
         // On récupère la locale la plus appropriée à la langue
         $this->_sToLocale = Locale::buildFromLang($sLocaleOrLang);
         $this->_sToLanguage = $sLocaleOrLang;
     } else {
         if (!Locale::isValid($sLocaleOrLang)) {
             throw ExceptionType::domain("La locale définie n'est pas valide.", Exception::FROM_HANDLER);
         }
         $this->_sToLocale = $sLocaleOrLang;
         // On déduit la langue de la locale
         if (preg_match('`(^[a-zA-Z]+)`', $this->_sToLocale, $aMatch)) {
             $this->_sToLanguage = $aMatch[1];
         }
     }
 }