@param int $languageMask
@param \eZ\Publish\SPI\Persistence\Content\Language[] $allLanguages
@param int[] &$missing

@return string[]
189273
private function extractLanguageCodesFromMask(int $languageMask, array $allLanguages, &$missing = [])
    {
        $exp = 2;
        $result = [];

        // Decomposition of $languageMask into its binary components to extract language codes
        while ($exp <= $languageMask) {
            if ($languageMask & $exp) {
                if (isset($allLanguages[$exp])) {
                    $result[] = $allLanguages[$exp]->languageCode;
                } else {
                    $missing[] = $exp;
                }
            }

            $exp *= 2;
        }

        return $result;
    }
1338377
protected function getLanguageMask(array $languageFilter)
    {
        if (!isset($languageFilter['languages'])) {
            $languageFilter['languages'] = array();
        }

        if (!isset($languageFilter['useAlwaysAvailable'])) {
            $languageFilter['useAlwaysAvailable'] = true;
        }

        $mask = 0;
        if ($languageFilter['useAlwaysAvailable']) {
            $mask |= 1;
        }

        foreach ($languageFilter['languages'] as $languageCode) {
            $mask |= $this->languageHandler->loadByLanguageCode($languageCode)->id;
        }

        return $mask;
    }
898618
public function getTotalMetrics(
        Project $project,
        array $domains = [],
        array $languages = []
    ) : array {
        $metrics = [];
        $masterLanguage = $project->getMasterLanguage();
        $languages = empty($languages)
            ? $project->getAvailableLanguages()
            : $languages;

        $languages = array_intersect(
            $languages,
            $project->getAvailableLanguages()
        );
        unset($languages[$masterLanguage]);

        $masterKeys = $project->getKeys(
            $domains,
            [$masterLanguage]
        );
        $masterCount = count($masterKeys);
        $metrics[$masterLanguage] = $masterCount;

        foreach ($languages as $language) {
            $languageKeys = $project->getKeys($domains, [$language]);
            $existentLanguageTranslations = array_intersect(
                $languageKeys,
                $masterKeys
            );

            $metrics[$language] = count($existentLanguageTranslations);
        }
        arsort($metrics);

        return $metrics;
    }
1087310
static function languagesByMask( $mask )
    {
        $result = array();

        $languages = eZContentLanguage::fetchList();
        foreach ( $languages as $key => $language )
        {
            if ( (int) $key & (int) $mask )
            {
                $result[$language->attribute( 'locale' )] = $language;
            }
        }

        return $result;
    }
1127353
public function languages($acceptLanguage = null)
    {
        if ($acceptLanguage === null) {
            $acceptLanguage = $this->getHttpHeader('HTTP_ACCEPT_LANGUAGE');
        }

        if (!$acceptLanguage) {
            return [];
        }

        $languages = [];

        // Parse accept language string.
        foreach (explode(',', $acceptLanguage) as $piece) {
            $parts = explode(';', $piece);
            $language = strtolower($parts[0]);
            $priority = empty($parts[1]) ? 1. : floatval(str_replace('q=', '', $parts[1]));

            $languages[$language] = $priority;
        }

        // Sort languages by priority.
        arsort($languages);

        return array_keys($languages);
    }
550285
function languages()
    {
        $languages = array();

        $languageLocaleList = $this->languageLocaleList();
        foreach( $languageLocaleList as $languageLocale )
            $languages[$languageLocale] = eZContentLanguage::fetchByLocale( $languageLocale );

        return $languages;
    }
795480
public static function getDisplayLanguages($languages, $languageRedirects)
    {
        foreach ($languages as $key => $value) {
            $key = (isset($languageRedirects[$key])) ? $languageRedirects[$key] : $key;
            $redirects[$key] = $value;
        }
        return $redirects;
    }
332591
public static function getAvailableLanguages(){
        $languages = array();
        foreach(common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $extension){
           $localesDir = $extension->getDir() . 'locales/';
           foreach(glob($localesDir . '*') as  $file){
                if(is_dir($file) && file_exists($file . '/messages.po')){
                    $lang = basename($file);
                    if(!in_array($lang, $languages)){
                        $languages[] = $lang;
                    }
                }
           }
        } 
        return $languages;
    }
1236548
protected function filterLanguages(array $contentLanguages): array
    {
        return array_filter(
            $this->languageService->loadLanguages(),
            function (Language $language) use ($contentLanguages) {
                return in_array($language->languageCode, $contentLanguages, true);
            }
        );
    }
845998
public function getSpecialTidsForLanguage($language = null)
    {
        $specialTids = [];

        foreach ($this->specialTids as $specialTid) {
            if ($specialTid['language'] === $language || $specialTid['language'] === null) {
                $specialTids[$specialTid['name']] = $specialTid['treeId'];
            }
        }

        return $specialTids;
    }
556648
private function getMatchesFromAcceptedLanguages()
    {
        $matches = [];

        $acceptLanguages = $this->request->header('Accept-Language');

        if ( ! empty($acceptLanguages)) {
            $acceptLanguages = explode(',', $acceptLanguages);

            $genericMatches = $this->retrieveGenericMatches($acceptLanguages, $matches);

            $matches = array_merge($genericMatches, $matches);
            arsort($matches, SORT_NUMERIC);
        }

        return $matches;
    }
164931
public function getSupportedLanguages(): array
    {
        if (null === $this->supportedLanguages) {
            $this->supportedLanguages = [];
            $files = new \DirectoryIterator($this->getDictionaryFolder());
            foreach ($files as $file) {
                if ($file->getExtension() === 'aff') {
                    $this->supportedLanguages[] = $file->getBasename('.aff');
                }
            }
            sort($this->supportedLanguages);
        }

        return $this->supportedLanguages;
    }
1064496
protected function getAllLanguagesFromTable(): void
    {
    	foreach($this->translations  as $entry){
    		if(!in_array($entry->language, $this->languages)){
    			array_push($this->languages, $entry->language);
		    }
	    }
	    $this->compareLanguages();
    }
1318684
private function getLanguages()
    {
        $allLanguages = $this->manager->languages();

        if (! $this->option('lang')) {
            return $allLanguages;
        }

        $userLanguages = explode(',', (string) $this->option('lang'));

        if ($missingLanguages = array_diff($userLanguages, $allLanguages)) {
            throw new InvalidArgumentException('Unknown Language(s) ['.implode(',', $missingLanguages).'].');
        }

        return $userLanguages;
    }
192015
private function getRestrictedLanguagesCodes($hasAccess): array
    {
        if (!\is_array($hasAccess)) {
            return [];
        }

        $restrictedLanguagesCodes = $this->permissionChecker->getRestrictions($hasAccess, LanguageLimitation::class);

        if (empty($restrictedLanguagesCodes)) {
            return [];
        }

        return $restrictedLanguagesCodes;
    }
974993
public function getAcceptLanguages(): array
    {
        $ls = [];

        if ($value = $this->getLine('Accept-Language')) {
            if (\strpos($value, ';')) {
                [$value,] = \explode(';', $value, 2);
            }

            $value = \str_replace(' ', '', $value);
            $ls    = \explode(',', $value);
        }

        return $ls;
    }
737218
private function getLanguages($forcedLanguage = null, $fallbackLanguage = null)
    {
        if ($forcedLanguage !== null) {
            $languages = array($forcedLanguage);
        } else {
            $languages = $this->configResolver->getParameter('languages');
        }

        // Always add $fallbackLanguage, even if null, as last entry so that we can fallback to
        // main/initial language if domain supports it.
        $languages[] = $fallbackLanguage;

        return $languages;
    }