Get the locales that should be translated
@return array containing the locales to use
769335
protected static function get_target_locales()
    {
        // if locales are explicitly set, use these
        if (is_array(self::config()->locales)) {
            return (array)self::config()->locales;
            // otherwise check the allowed locales. If these have been set, use these
        } else if (is_array(Translatable::get_allowed_locales())) {
            return (array)Translatable::get_allowed_locales();
        }

        // last resort is to take the existing content languages
        return array_keys(Translatable::get_existing_content_languages());
    }
121506
public static function activeLocales(): array
    {
        $locales = app(ModuleService::class)
            ->findByInterface(ModuleLanguageInterface::class, false, true)
            ->map(static function (ModuleLanguageInterface $module): LocaleInterface {
                return $module->locale();
            });

        if ($locales->isEmpty()) {
            return [new LocaleEnUs()];
        }

        return $locales->all();
    }
1317470
protected function buildAlternateTranslations()
    {
        $translations = [];

        $context  = $this->contextObject();
        $origLang = $this->currentLanguage();

        $this->translator()->isIteratingLocales = true;
        foreach ($this->locales() as $langCode => $localeStruct) {
            if ($langCode === $origLang) {
                continue;
            }

            $this->translator()->setLocale($langCode);

            $translations[$langCode] = $this->formatAlternateTranslation($context, $localeStruct);
        }

        $this->translator()->setLocale($origLang);
        unset($this->translator()->isIteratingLocales);

        return $translations;
    }
1043955
public function getLanguagesWithMasterLanguagePromoted()
    {
        $languages = $this
            ->languageManager
            ->getLanguages()
            ->toArray();

        $masterLocale = $this
            ->masterLocale
            ->getIso();

        $index = array_search($masterLocale, $languages);

        if (false !== $index) {
            $mainLanguage = $languages[$index];
            unset($languages[$index]);
            array_unshift($languages, $mainLanguage);
        }

        return new ArrayCollection($languages);
    }
226091
public function getAvailableLangs(): array
    {
        $langs = ['en'];
        $scan = Directory::scan(root . '/I18n/' . env_name . '/', GLOB_ONLYDIR, true);
        foreach ($scan as $row) {
            $langs[] = trim($row, '/');
        }
        return $langs;
    }
219638
public static function getAvailableLocalesInfo()
    {
        $languages = [];
        foreach (static::getAvailableLocales() as $id) {
            $languages[$id] = new Language($id);
        }

        return $languages;
    }
1056277
public function availableLocales()
    {
        $locales = $this->getCore()->config('locale.translation-locales');

        if (is_array($locales)) {
            return $locales;
        }

        return $this->getLocaleRepository()->getAvailable();
    }
290169
public function getAvailableLocales() {

		foreach($this->locales as $id => $l) {
			if(!$l) {
				$this->locales[$id] = new Locale($id);
			}
		}

		return $this->locales;
	}
80578
public static function optionsInstalledLanguages(): array
    {
        $languages = [];
        foreach (I18N::installedLocales() as $locale) {
            $languages[$locale->languageTag()] = $locale->endonym();
        }

        return $languages;
    }
1362178
public function getMessagesArray()
    {
        $result = [];
        foreach ($this->getMessages() as $message) {
            $result[$message->getLocale()] = $message;
        }

        return $result;
    }
955428
public function getAllLocalizations()
    {
        $localizations = [];
        foreach ($this->getLocalizations() as $child) {
            $localizations[] = $child;
            $localizations = array_merge($localizations, $child->getAllLocalizations());
        }

        return $localizations;
    }
974991
public function getI18nPaths()
	{
		$paths = array();

		foreach ( $this->_manifests as $basePath => $manifest )
		{
			if ( isset( $manifest['i18n'] ) )
			{
				foreach( $manifest['i18n'] as $domain => $location ) {
					$paths[$domain][] = $basePath . DIRECTORY_SEPARATOR . $location;
				}
			}
		}

		return $paths;
	}
769768
public function getLocales()
	{
		$currentLocales = array();
		
		foreach($this->localeCategories as $category) {
			if($category === LC_ALL)
				continue;
			
			$currentLocales[$category] = setlocale($category, 0);
		}
		
		return $currentLocales;
	}
120730
public function translationsFolders()
    {
        $locale = Locale::parseLocale($this->_locale) + ['region' => null];

        $folders = [
            implode('_', [$locale['language'], $locale['region']]),
            $locale['language']
        ];

        $searchPaths = [];

        $localePaths = App::path('Locale');
        if (empty($localePaths) && defined('APP')) {
            $localePaths[] = APP . 'Locale' . DIRECTORY_SEPARATOR;
        }
        foreach ($localePaths as $path) {
            foreach ($folders as $folder) {
                $searchPaths[] = $path . $folder . DIRECTORY_SEPARATOR;
            }
        }

        // If space is not added after slash, the character after it remains lowercased
        $pluginName = Inflector::camelize(str_replace('/', '/ ', $this->_name));
        if (Plugin::isLoaded($pluginName)) {
            $basePath = Plugin::classPath($pluginName) . 'Locale' . DIRECTORY_SEPARATOR;
            foreach ($folders as $folder) {
                $searchPaths[] = $basePath . $folder . DIRECTORY_SEPARATOR;
            }
        }

        return $searchPaths;
    }
1140404
public static function get_encodings() {
        $encodings = array();
        $encodings['UTF-8'] = 'UTF-8';
        $winenc = strtoupper(get_string('localewincharset', 'langconfig'));
        if ($winenc != '') {
            $encodings[$winenc] = $winenc;
        }
        $nixenc = strtoupper(get_string('oldcharset', 'langconfig'));
        $encodings[$nixenc] = $nixenc;

        foreach (self::typo3()->synonyms as $enc) {
            $enc = strtoupper($enc);
            $encodings[$enc] = $enc;
        }
        return $encodings;
    }
1187204
public function getUsedLanguages() {
		$alllanguages = $this->getAllLanguages();
		
		$usedlanguages = array();
		
		foreach ($alllanguages as $code=>$lang) {
			// check if lang folder and default file exists
			$langfile = $this->localespath.$code.'/default.txt';
			
			if (file_exists($langfile)) {
				$usedlanguages[$code] = $lang;
			}
		}
		
		return $usedlanguages;
	}
1294968
public function getApprovedLocales()
    {
        $locales = $this->findBy(['isSource' => null, 'isApproved' => true]);
        $comparer = new Comparer();
        usort($locales, function (LocaleEntity $a, LocaleEntity $b) use ($comparer) {
            return $comparer->compare($a->getDisplayName(), $b->getDisplayName());
        });

        return $locales;
    }