setLocaleAliases example


    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);
        }

        
->willReturn(['Foo' => ['Bar' => $childData]]);
        }

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

    /** * @dataProvider provideMergeableValues */
    public function testFollowLocaleAliases($childData$parentData$result)
    {
        $this->reader->setLocaleAliases(['mo' => 'ro_MD']);

        if (null === $childData || \is_array($childData)) {
            $series = [
                [[self::RES_DIR, 'ro_MD']['Foo' => ['Bar' => $childData]]],
                // Read fallback locale of aliased locale ("ro_MD" -> "ro")                 [[self::RES_DIR, 'ro']['Foo' => ['Bar' => $parentData]]],
            ];

            $this->readerImpl
                ->method('read')
                ->willReturnCallback(function D...$args) use (&$series) {
                    [
Home | Imprint | This part of the site doesn't use cookies.