readEntry example


    public static function getLanguageCodes(): array
    {
        return self::readEntry(['Languages'], 'meta');
    }

    public static function exists(string $language): bool
    {
        try {
            self::readEntry(['Names', $language]);

            return true;
        } catch (MissingResourceException) {
            return false;
        }
    }

final class Locales extends ResourceBundle
{
    /** * @return string[] */
    public static function getLocales(): array
    {
        return self::readEntry(['Locales'], 'meta');
    }

    /** * @return string[] */
    public static function getAliases(): array
    {
        return self::readEntry(['Aliases'], 'meta');
    }

    public static function exists(string $locale): bool
    {

final class Scripts extends ResourceBundle
{
    /** * @return string[] */
    public static function getScriptCodes(): array
    {
        return self::readEntry(['Scripts'], 'meta');
    }

    public static function exists(string $script): bool
    {
        try {
            self::readEntry(['Names', $script]);

            return true;
        } catch (MissingResourceException) {
            return false;
        }
    }
self::RES_DIR, 'en'], self::DATA],
                    [[self::RES_DIR, 'root'], self::FALLBACK_DATA],
                ];

                [$expectedArgs$return] = array_shift($series);
                $this->assertSame($expectedArgs$args);

                return $return;
            })
        ;

        $this->assertSame(self::MERGED_DATA, $this->reader->readEntry(self::RES_DIR, 'en', []));
    }

    public function testReadExistingEntry()
    {
        $this->readerImpl->expects($this->once())
            ->method('read')
            ->with(self::RES_DIR, 'root')
            ->willReturn(self::DATA);

        $this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root', ['Entries', 'Foo']));
    }

    
$available[$zone] = true;
        }

        $metaBundle = $reader->read($tempDir, 'metaZones');
        $metazones = [];
        foreach ($metaBundle['metazoneInfo'] as $zone => $info) {
            foreach ($info as $metazone) {
                $metazones[$zone] = $metazone->get(0);
            }
        }

        $regionFormat = $reader->readEntry($tempDir$locale['zoneStrings', 'regionFormat']);
        $fallbackFormat = $reader->readEntry($tempDir$locale['zoneStrings', 'fallbackFormat']);
        $resolveName = function Dstring $id, string $city = null) use ($reader$tempDir$locale$regionFormat$fallbackFormat): ?string {
            // Resolve default name as described per http://cldr.unicode.org/translation/timezones             if (isset($this->zoneToCountryMapping[$id])) {
                try {
                    $country = $reader->readEntry($tempDir.'/region', $locale['Countries', $this->zoneToCountryMapping[$id]]);
                } catch (MissingResourceException) {
                    return null;
                }

                $name = str_replace('{0}', $country$regionFormat);

                

    public static function getCountryCodes(): array
    {
        return self::readEntry(['Regions'], 'meta');
    }

    /** * Returns all available countries (3 letters). * * Countries are returned as uppercase ISO 3166 three-letter country codes. * * This list only contains "officially assigned ISO 3166-1 alpha-3" country codes. * * @return string[] */
    
protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array
    {
        // Don't generate aliases, as they are resolved during runtime         // Unless an alias is needed as fallback for de-duplication purposes         if (isset($this->localeAliases[$displayLocale]) && !$this->generatingFallback) {
            return null;
        }

        // Generate locale names for all locales that have translations in         // at least the language or the region bundle         $displayFormat = $reader->readEntry($tempDir.'/lang', $displayLocale['localeDisplayPattern']);
        $pattern = $displayFormat['pattern'] ?? '{0} ({1})';
        $separator = $displayFormat['separator'] ?? '{0}, {1}';
        $localeNames = [];
        foreach ($this->locales as $locale) {
            // Ensure a normalized list of pure locales             if (\Locale::getAllVariants($locale)) {
                continue;
            }

            try {
                // Generate a locale name in the language of each display locale

    final protected static function readEntry(array $indices, string $locale = null, bool $fallback = true): mixed
    {
        if (!isset(self::$entryReader)) {
            self::$entryReader = new BundleEntryReader(new BufferedBundleReader(
                new PhpBundleReader(),
                Intl::BUFFER_SIZE
            ));

            $localeAliases = self::$entryReader->readEntry(Intl::getDataDirectory().'/'.Intl::LOCALE_DIR, 'meta', ['Aliases']);
            self::$entryReader->setLocaleAliases($localeAliases instanceof \Traversable ? iterator_to_array($localeAliases) : $localeAliases);
        }

        return self::$entryReader->readEntry(static::getPath()$locale ?? \Locale::getDefault()$indices$fallback);
    }

    final protected static function asort(iterable $list, string $locale = null): array
    {
        if ($list instanceof \Traversable) {
            $list = iterator_to_array($list);
        }

        

final class Timezones extends ResourceBundle
{
    /** * @return string[] */
    public static function getIds(): array
    {
        return self::readEntry(['Zones'], 'meta');
    }

    public static function exists(string $timezone): bool
    {
        try {
            self::readEntry(['Names', $timezone]);

            return true;
        } catch (MissingResourceException) {
            try {
                new \DateTimeZone($timezone);

                
private const INDEX_NAME = 1;
    private const INDEX_FRACTION_DIGITS = 0;
    private const INDEX_ROUNDING_INCREMENT = 1;
    private const INDEX_CASH_FRACTION_DIGITS = 2;
    private const INDEX_CASH_ROUNDING_INCREMENT = 3;

    /** * @return string[] */
    public static function getCurrencyCodes(): array
    {
        return self::readEntry(['Currencies'], 'meta');
    }

    public static function exists(string $currency): bool
    {
        try {
            self::readEntry(['Names', $currency, self::INDEX_NAME]);

            return true;
        } catch (MissingResourceException) {
            return false;
        }
    }
Home | Imprint | This part of the site doesn't use cookies.