Пример #1
0
 /**
  * Method to test getLocaliseClassPrefix().
  *
  * @return void
  *
  * @covers Windwalker\Language\LanguageNormalize::getLocaliseClassPrefix
  */
 public function testGetLocaliseClassPrefix()
 {
     $this->assertEquals('EnGB', LanguageNormalize::getLocaliseClassPrefix('en_gb'));
     $this->assertEquals('EnGB', LanguageNormalize::getLocaliseClassPrefix('EN_GB'));
     $this->assertEquals('EnGB', LanguageNormalize::getLocaliseClassPrefix('en-gb'));
     $this->assertEquals('EnGB', LanguageNormalize::getLocaliseClassPrefix('EN-gB'));
 }
Пример #2
0
 /**
  * getLocalise
  *
  * @param string $locale
  *
  * @return  LocaliseInterface
  */
 protected function getLocalise($locale = 'en-GB')
 {
     $locale = LanguageNormalize::toLanguageTag($locale);
     if (empty($this->localises[$locale]) || !$this->localises[$locale] instanceof LocaliseInterface) {
         $tag = LanguageNormalize::getLocaliseClassPrefix($this->locale);
         $class = sprintf('Windwalker\\Language\\Localise\\%sLocalise', $tag);
         if (!class_exists($class)) {
             $class = 'Windwalker\\Language\\Localise\\NullLocalise';
         }
         $this->localises[$locale] = new $class();
     }
     return $this->localises[$locale];
 }