/**
  * @since 2.4
  *
  * @return ExtraneousLanguage
  */
 public static function getInstance()
 {
     if (self::$instance !== null) {
         return self::$instance;
     }
     // $cache = ApplicationFactory::getInstance()->getCache()
     $languageJsonFileContentsReader = new LanguageJsonFileContentsReader();
     //$languageFileContentsReader->setCachePrefix( $cacheFactory->getCachePrefix() )
     self::$instance = new self(new LanguageContents($languageJsonFileContentsReader, new LanguageFallbackFinder($languageJsonFileContentsReader)));
     self::$instance->setHistoricTypeNamespace($GLOBALS['smwgHistoricTypeNamespace']);
     return self::$instance;
 }
 protected function getNamespacesByLanguageCode($languageCode)
 {
     $GLOBALS['smwgContLang'] = $this->extraneousLanguage->fetchByLanguageCode($languageCode);
     return $GLOBALS['smwgContLang']->getNamespaces();
 }
 /**
  * @dataProvider canonicalPropertyLabelsProvider
  */
 public function testGetCanonicalPropertyLabels($languageCode, $aliasMatch, $expected)
 {
     $extraneousLanguage = ExtraneousLanguage::getInstance()->fetchByLanguageCode($languageCode);
     $propertyLabels = $extraneousLanguage->getCanonicalPropertyLabels();
     $this->assertEquals($expected, $propertyLabels[$aliasMatch]);
 }
Example #4
0
 /**
  * @since 2.4
  *
  * @param Language|string $languageCode
  *
  * @return ExtraneousLanguage
  */
 public function getExtraneousLanguage($language = '')
 {
     $languageCode = $language;
     if ($language instanceof Language) {
         $languageCode = $language->getCode();
     }
     if ($languageCode === '' || !$languageCode || $languageCode === null) {
         $languageCode = $this->getContentLanguage()->getCode();
     }
     return ExtraneousLanguage::getInstance()->fetchByLanguageCode($languageCode);
 }
 /**
  * @since 1.9.0.2
  *
  * @param ExtraneousLanguage $extraneousLanguage
  */
 public function __construct(ExtraneousLanguage $extraneousLanguage)
 {
     $typeLabels = $extraneousLanguage->getDatatypeLabels();
     $typeAliases = $extraneousLanguage->getDatatypeAliases();
     $canonicalLabels = $extraneousLanguage->getCanonicalDatatypeLabels();
     foreach ($typeLabels as $typeId => $typeLabel) {
         $this->registerTypeLabel($typeId, $typeLabel);
     }
     foreach ($typeAliases as $typeAlias => $typeId) {
         $this->registerDataTypeAlias($typeId, $typeAlias);
     }
     foreach ($canonicalLabels as $label => $id) {
         $this->canonicalLabels[$id] = $label;
     }
 }
 public function testGetMonthLabelByNumber()
 {
     $contents = array(array('January', 'Jan'), array('February', 'Feb'), array('March', 'Mar'));
     $languageContents = $this->getMockBuilder(LanguageContents::class)->disableOriginalConstructor()->getMock();
     $languageContents->expects($this->atLeastOnce())->method('getContentsByLanguageWithIndex')->with($this->anything(), $this->equalTo('months'))->will($this->returnValue($contents));
     $instance = new ExtraneousLanguage($languageContents);
     $this->assertEquals('March', $instance->getMonthLabelByNumber(3));
 }
 private function loadLanguageFileAndConstructClass($langcode)
 {
     return ExtraneousLanguage::getInstance()->fetchByLanguageCode($langcode);
 }