Fetches the language identified by locale code.

\param locale Locale of the language to fetch, e. g. 'slk-SK'.
\return eZContentLanguage object identified by locale code $locale.
488919
static function fetchByLocale( $locale, $createIfNotExist = false )
    {
        $languages = eZContentLanguage::fetchList();

        foreach ( $languages as $language )
        {
            if ( $language->attribute( 'locale' ) == $locale )
            {
                return $language;
            }
        }

        $language = false;
        if ( $createIfNotExist )
        {
            $language = eZContentLanguage::addLanguage( $locale );
        }

        return $language;
    }
533329
public function getTranslationByLocale($locale)
    {
        foreach ($this->getTranslations() as $valueTranslation) {
            if ($valueTranslation->getLocale() === $locale) {
                return $valueTranslation;
            }
        }

        return null;
    }
1239739
public function get($locale = 'en')
	{
		if (isset($this->stopwords[$locale])) {
			return $this->stopwords[$locale];
		}

		$this->stopwords[$locale] = [];

		$filename = $this->path . '/' . $locale . '.php';

		if (file_exists($filename)) {
			$this->stopwords[$locale] = require $filename;
		}

		return $this->stopwords[$locale];
	}
1176626
@Override
    public String getEncodingFromLocale(Locale locale) {
        if (null == locale) {
            return null;
        }
        if (locale.equals(this.cachedLocale)) {
            return this.cachedEncoding;
        }

        String encoding = localeMap.get(locale.toString());
        if (null == encoding) {
            final String lang = locale.getLanguage();
            encoding = localeMap.get(lang + '_' + locale.getCountry());
            if (null == encoding) {
                encoding = localeMap.get(lang);
            }
        }

        this.cachedEncoding = encoding;
        this.cachedLocale = locale;

        return encoding;
    }
215629
public static LocaleData get(Locale locale) {
        if (locale == null) {
            throw new NullPointerException("locale == null");
        }

        final String languageTag = locale.toLanguageTag();
        synchronized (localeDataCache) {
            LocaleData localeData = localeDataCache.get(languageTag);
            if (localeData != null) {
                return localeData;
            }
        }
        LocaleData newLocaleData = initLocaleData(locale);
        synchronized (localeDataCache) {
            LocaleData localeData = localeDataCache.get(languageTag);
            if (localeData != null) {
                return localeData;
            }
            localeDataCache.put(languageTag, newLocaleData);
            return newLocaleData;
        }
    }
390000
public function findByLangCode($locale, $code)
    {
        list($namespace, $group, $item) = $this->parseCode($code);
        return $this->model->whereLocale($locale)->whereNamespace($namespace)->whereGroup($group)->whereItem($item)->first();
    }
182272
public function getLocaleChain(Locale $locale)
    {
        $fallbackRule = $this->configuration->getFallbackRule();
        $localeChain = [(string)$locale => $locale];

        if ($fallbackRule['strict'] === true) {
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $localeChain[$localeIdentifier] = new Locale($localeIdentifier);
            }
        } else {
            $locale = $this->findBestMatchingLocale($locale);
            while ($locale !== null) {
                $localeChain[(string)$locale] = $locale;
                $locale = $this->getParentLocaleOf($locale);
            }
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $locale = new Locale($localeIdentifier);
                $locale = $this->findBestMatchingLocale($locale);
                while ($locale !== null) {
                    $localeChain[(string)$locale] = $locale;
                    $locale = $this->getParentLocaleOf($locale);
                }
            }
        }
        $locale = $this->configuration->getDefaultLocale();
        $localeChain[(string)$locale] = $locale;

        return $localeChain;
    }
1355686
public function getTranslationFile($locale)
    {
        if (isset($this->locales[$locale]) === false) {
            return null;
        }

        return $this->locales[$locale];
    }
129122
public function getTranslations($locale)
    {
        //Default locale
        if (null === $locale) {
            $locale = Config::getParam('default.language', 'es_ES');
        }

        //Generating the templates translations
        $translations = $this->tpl->regenerateTemplates();

        $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
        $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR;

        //xgettext localizations
        $translations = array_merge($translations, GeneratorService::findTranslations(SOURCE_DIR, $locale));
        $translations = array_merge($translations, GeneratorService::findTranslations(CORE_DIR, $locale));
        $translations = array_merge($translations, GeneratorService::findTranslations(CACHE_DIR, $locale));

        $translations[] = "msgfmt {$localePath}translations.po -o {$localePath}translations.mo";
        $translations[] = shell_exec('export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt '. $localePath . 'translations.po -o ' . $localePath . 'translations.mo');
        return $this->render('translations.html.twig', array(
            'translations' => $translations,
        ));
    }
507807
protected function getTranslationOrNew( $locale )
    {
        if( ( $translation = $this->getTranslation( $locale, false ) ) === null )
        {
            $translation = $this->getNewTranslation( $locale );
        }

        return $translation;
    }
396330
public function getLocalization($locale)
	{
		$localization = parent::getLocalization($locale);
		
		// Create fake localization if not persisted
		if (is_null($localization)) {
			$localization = $this->createLocalization($locale);
		}
		
		return $localization;
	}
879532
public function language($locale = null)
    {
        if ($locale !== null) {
            $this->language = $locale;
        }

        return $this->language;
    }
1232357
private function getLocaleCode($locale)
    {
        $locales = explode('_', strtolower($locale));
        $locale = array_pop($locales);

        if ('en' === $locale) {
            $locale = 'gb';
        }

        return $locale;
    }
205167
public function getTranslations(Locale $locale)
    {
        $localeID = $locale->getID();
        $translations = isset($this->translations[$localeID]) ? $this->translations[$localeID][1] : null;
        if ($translations === null) {
            $translations = clone $this->getSourceStrings(true);
            $translations->setLanguage($locale->getID());
            $this->setTranslations($locale, $translations);
        }

        return $translations;
    }
1034279
private function getLocaleId(string $locale): string
    {
        if (isset($this->localeToIdMapping[$locale])) {
            return $this->localeToIdMapping[$locale];
        }

        throw new StorageException(sprintf('Id for locale "%s" has not been configured.', $locale));
    }
783182
public function load($locale)
    {
        if (isset($this->cache[$locale])) {
            return $this->cache[$locale];
        }

        // New Translator array
        $trans = [];
        // Split the language: language, region, locale, etc
        $parts = string_split($locale, '-');

        do {
            // Create a path for this set of parts
            $path = implode(DS, $parts);

            // Remove the last part
            if ($files = $this->findLanguageFile($path)) {
                $trans = $this->loadMessages($files, $trans);
            }

            array_pop($parts);
        } while ($parts);

        // Cache the Translator table locally
        return $this->cache[$locale] = $trans;
    }
247055
public function getByLocale(LocaleEntity $locale)
    {
        $app = Application::getFacadeApplication();
        $result = $this->find($locale);
        if ($result === null) {
            $em = $this->getEntityManager();
            try {
                $numTranslatable = (int) $app->make(TranslatableRepository::class)
                    ->createQueryBuilder('t')
                        ->select('count(t.id)')
                        ->getQuery()->getSingleScalarResult();
            } catch (NoResultException $x) {
                $numTranslatable = 0;
            }
            if ($numTranslatable === 0) {
                $numApprovedTranslations = 0;
            } else {
                try {
                    $numApprovedTranslations = (int) $app->make(TranslationRepository::class)
                    ->createQueryBuilder('t')
                        ->select('count(t.id)')
                        ->where('t.locale = :locale')->setParameter('locale', $locale)
                        ->andWhere('t.current = 1')
                        ->getQuery()->getSingleScalarResult();
                } catch (NoResultException $x) {
                    $numApprovedTranslations = 0;
                }
            }
            $result = LocaleStatsEntity::create($locale, $numTranslatable, $numApprovedTranslations);
            $em->persist($result);
            $em->flush($result);
        }

        return $result;
    }