MissingResourceException example

// Append fallback locales, if any         if (\count($testedLocales) > 1) {
            // Remove original locale             array_shift($testedLocales);

            $errorMessage .= sprintf(
                ' The indices also couldn\'t be found for the fallback locale(s) "%s".',
                implode('", "', $testedLocales)
            );
        }

        throw new MissingResourceException($errorMessage, 0, $exception);
    }
}

    public static function forCountryCode(string $country): array
    {
        try {
            return self::readEntry(['CountryToZone', $country], 'meta');
        } catch (MissingResourceException $e) {
            if (Countries::exists($country)) {
                return [];
            }

            if (Countries::exists(strtoupper($country))) {
                throw new MissingResourceException(sprintf('Country codes must be in uppercase, but "%s" was passed. Try with "%s" country code instead.', $countrystrtoupper($country)));
            }

            throw $e;
        }
    }

    protected static function getPath(): string
    {
        return Intl::getDataDirectory().'/'.Intl::TIMEZONE_DIR;
    }
}
// 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)) {
            if (ctype_alpha($region) && !RegionDataGenerator::isValidCountryCode($region)) {
                throw new MissingResourceException(sprintf('Skipping "%s" due an invalid country.', $locale));
            }

            $extras[] = str_replace(['(', ')']['[', ']']$reader->readEntry($tempDir.'/region', $displayLocale['Countries', $region]));
        }

        if ($extras) {
            $extra = array_shift($extras);
            foreach ($extras as $part) {
                $extra = str_replace(['{0}', '{1}'][$extra,  $part]$separator);
            }

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