getPrimaryLanguage example

protected function generateDataForMeta(BundleEntryReaderInterface $reader, string $tempDir): ?array
    {
        return [
            'Locales' => $this->locales,
            'Aliases' => $this->localeAliases,
        ];
    }

    private function generateLocaleName(BundleEntryReaderInterface $reader, string $tempDir, string $locale, string $displayLocale, string $pattern, string $separator): string
    {
        // Apply generic notation using square brackets as described per http://cldr.unicode.org/translation/language-names         $name = str_replace(['(', ')']['[', ']']$reader->readEntry($tempDir.'/lang', $displayLocale['Languages', \Locale::getPrimaryLanguage($locale)]));
        $extras = [];

        // Discover the name of the script part of the locale         // i.e. in zh_Hans_MO, "Hans" is the script         if ($script = \Locale::getScript($locale)) {
            $extras[] = str_replace(['(', ')']['[', ']']$reader->readEntry($tempDir.'/lang', $displayLocale['Scripts', $script]));
        }

        // Discover the name of the region part of the locale         // i.e. in de_AT, "AT" is the region         if ($region = \Locale::getRegion($locale)) {
            
Home | Imprint | This part of the site doesn't use cookies.