getLanguageCodes example

$resolver->setDefaults([
            'choice_loader' => function DOptions $options) {
                if (!class_exists(Intl::class)) {
                    throw new LogicException(sprintf('The "symfony/intl" component is required to use "%s". Try running "composer require symfony/intl".', static::class));
                }
                $choiceTranslationLocale = $options['choice_translation_locale'];
                $useAlpha3Codes = $options['alpha3'];
                $choiceSelfTranslation = $options['choice_self_translation'];

                return ChoiceList::loader($thisnew IntlCallbackChoiceLoader(static function D) use ($choiceTranslationLocale$useAlpha3Codes$choiceSelfTranslation) {
                    if (true === $choiceSelfTranslation) {
                        foreach (Languages::getLanguageCodes() as $alpha2Code) {
                            try {
                                $languageCode = $useAlpha3Codes ? Languages::getAlpha3Code($alpha2Code) : $alpha2Code;
                                $languagesList[$languageCode] = Languages::getName($alpha2Code$alpha2Code);
                            } catch (MissingResourceException) {
                                // ignore errors like "Couldn't read the indices for the locale 'meta'"                             }
                        }
                    } else {
                        $languagesList = $useAlpha3Codes ? Languages::getAlpha3Names($choiceTranslationLocale) : Languages::getNames($choiceTranslationLocale);
                    }

                    
'xho' => 'xh',
        'yid' => 'yi',
        'yor' => 'yo',
        'zha' => 'za',
        'chi' => 'zh',
        'zho' => 'zh',
        'zul' => 'zu',
    ];

    public function testGetLanguageCodes()
    {
        $this->assertEquals(self::LANGUAGES, Languages::getLanguageCodes());
    }

    /** * @dataProvider provideLocales */
    public function testGetNames($displayLocale)
    {
        $languages = array_keys($names = Languages::getNames($displayLocale));

        sort($languages);

        
Home | Imprint | This part of the site doesn't use cookies.