This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Data\Provider\CurrencyDataProvider;
use Symfony\Component\Intl\Data\Provider\LocaleDataProvider;
use Symfony\Component\Intl\Exception\MissingResourceException;
/**
* Default implementation of {@link CurrencyBundleInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
class CurrencyBundle extends CurrencyDataProvider implements CurrencyBundleInterface
{
private $localeProvider;
/**
* Creates a new currency bundle.
*
* @param string $path
*/
public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider)
{
parent::__construct($path, $reader);
$this->localeProvider = $localeProvider;
}
/**
* {@inheritdoc}
*/
public function getCurrencySymbol($currency, $displayLocale = null)
{
try {
return $this->getSymbol($currency, $displayLocale);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getCurrencyName($currency, $displayLocale = null)
{
try {
return $this->getName($currency, $displayLocale);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getCurrencyNames($displayLocale = null)
{
try {
return $this->getNames($displayLocale);
} catch (MissingResourceException $e) {
return [];
}
}
/**
* {@inheritdoc}
*/
public function getFractionDigits($currency)
{
try {
return parent::getFractionDigits($currency);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getRoundingIncrement($currency)
{
try {
return parent::getRoundingIncrement($currency);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getLocales()
{
try {
return $this->localeProvider->getLocales();
} catch (MissingResourceException $e) {
return [];
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
/**
* Gives access to currency-related ICU data.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface CurrencyBundleInterface extends ResourceBundleInterface
{
/**
* Returns the symbol used for a currency.
*
* @param string $currency A currency code (e.g. "EUR")
* @param string $displayLocale Optional. The locale to return the result in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string|null The currency symbol or NULL if not found
*/
public function getCurrencySymbol($currency, $displayLocale = null);
/**
* Returns the name of a currency.
*
* @param string $currency A currency code (e.g. "EUR")
* @param string $displayLocale Optional. The locale to return the name in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string|null The name of the currency or NULL if not found
*/
public function getCurrencyName($currency, $displayLocale = null);
/**
* Returns the names of all known currencies.
*
* @param string $displayLocale Optional. The locale to return the names in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string[] A list of currency names indexed by currency codes
*/
public function getCurrencyNames($displayLocale = null);
/**
* Returns the number of digits after the comma of a currency.
*
* @param string $currency A currency code (e.g. "EUR")
*
* @return int|null The number of digits after the comma or NULL if not found
*/
public function getFractionDigits($currency);
/**
* Returns the rounding increment of a currency.
*
* The rounding increment indicates to which number a currency is rounded.
* For example, 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the
* nearest 0.65 is 1.3.
*
* @param string $currency A currency code (e.g. "EUR")
*
* @return float|int|null The rounding increment or NULL if not found
*/
public function getRoundingIncrement($currency);
}

View File

@@ -0,0 +1,113 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Data\Provider\LanguageDataProvider;
use Symfony\Component\Intl\Data\Provider\LocaleDataProvider;
use Symfony\Component\Intl\Data\Provider\ScriptDataProvider;
use Symfony\Component\Intl\Exception\MissingResourceException;
/**
* Default implementation of {@link LanguageBundleInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
class LanguageBundle extends LanguageDataProvider implements LanguageBundleInterface
{
private $localeProvider;
private $scriptProvider;
/**
* Creates a new language bundle.
*
* @param string $path
*/
public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider, ScriptDataProvider $scriptProvider)
{
parent::__construct($path, $reader);
$this->localeProvider = $localeProvider;
$this->scriptProvider = $scriptProvider;
}
/**
* {@inheritdoc}
*/
public function getLanguageName($language, $region = null, $displayLocale = null)
{
// Some languages are translated together with their region,
// i.e. "en_GB" is translated as "British English"
if (null !== $region) {
try {
return $this->getName($language.'_'.$region, $displayLocale);
} catch (MissingResourceException $e) {
}
}
try {
return $this->getName($language, $displayLocale);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getLanguageNames($displayLocale = null)
{
try {
return $this->getNames($displayLocale);
} catch (MissingResourceException $e) {
return [];
}
}
/**
* {@inheritdoc}
*/
public function getScriptName($script, $language = null, $displayLocale = null)
{
try {
return $this->scriptProvider->getName($script, $displayLocale);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getScriptNames($displayLocale = null)
{
try {
return $this->scriptProvider->getNames($displayLocale);
} catch (MissingResourceException $e) {
return [];
}
}
/**
* {@inheritdoc}
*/
public function getLocales()
{
try {
return $this->localeProvider->getLocales();
} catch (MissingResourceException $e) {
return [];
}
}
}

View File

@@ -0,0 +1,64 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
/**
* Gives access to language-related ICU data.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface LanguageBundleInterface extends ResourceBundleInterface
{
/**
* Returns the name of a language.
*
* @param string $language A language code (e.g. "en")
* @param string|null $region Optional. A region code (e.g. "US")
* @param string $displayLocale Optional. The locale to return the name in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string|null The name of the language or NULL if not found
*/
public function getLanguageName($language, $region = null, $displayLocale = null);
/**
* Returns the names of all known languages.
*
* @param string $displayLocale Optional. The locale to return the names in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string[] A list of language names indexed by language codes
*/
public function getLanguageNames($displayLocale = null);
/**
* Returns the name of a script.
*
* @param string $script A script code (e.g. "Hans")
* @param string $language Optional. A language code (e.g. "zh")
* @param string $displayLocale Optional. The locale to return the name in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string|null The name of the script or NULL if not found
*/
public function getScriptName($script, $language = null, $displayLocale = null);
/**
* Returns the names of all known scripts.
*
* @param string $displayLocale Optional. The locale to return the names in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string[] A list of script names indexed by script codes
*/
public function getScriptNames($displayLocale = null);
}

View File

@@ -0,0 +1,61 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
use Symfony\Component\Intl\Data\Provider\LocaleDataProvider;
use Symfony\Component\Intl\Exception\MissingResourceException;
/**
* Default implementation of {@link LocaleBundleInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
class LocaleBundle extends LocaleDataProvider implements LocaleBundleInterface
{
/**
* {@inheritdoc}
*/
public function getLocales()
{
try {
return parent::getLocales();
} catch (MissingResourceException $e) {
return [];
}
}
/**
* {@inheritdoc}
*/
public function getLocaleName($locale, $displayLocale = null)
{
try {
return $this->getName($locale, $displayLocale);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getLocaleNames($displayLocale = null)
{
try {
return $this->getNames($displayLocale);
} catch (MissingResourceException $e) {
return [];
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
/**
* Gives access to locale-related ICU data.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface LocaleBundleInterface extends ResourceBundleInterface
{
/**
* Returns the name of a locale.
*
* @param string $locale The locale to return the name of (e.g. "de_AT")
* @param string $displayLocale Optional. The locale to return the name in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string|null The name of the locale or NULL if not found
*/
public function getLocaleName($locale, $displayLocale = null);
/**
* Returns the names of all known locales.
*
* @param string $displayLocale Optional. The locale to return the names in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string[] A list of locale names indexed by locale codes
*/
public function getLocaleNames($displayLocale = null);
}

View File

@@ -0,0 +1,77 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
use Symfony\Component\Intl\Data\Provider\LocaleDataProvider;
use Symfony\Component\Intl\Data\Provider\RegionDataProvider;
use Symfony\Component\Intl\Exception\MissingResourceException;
/**
* Default implementation of {@link RegionBundleInterface}.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
class RegionBundle extends RegionDataProvider implements RegionBundleInterface
{
private $localeProvider;
/**
* Creates a new region bundle.
*
* @param string $path
*/
public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider)
{
parent::__construct($path, $reader);
$this->localeProvider = $localeProvider;
}
/**
* {@inheritdoc}
*/
public function getCountryName($country, $displayLocale = null)
{
try {
return $this->getName($country, $displayLocale);
} catch (MissingResourceException $e) {
return null;
}
}
/**
* {@inheritdoc}
*/
public function getCountryNames($displayLocale = null)
{
try {
return $this->getNames($displayLocale);
} catch (MissingResourceException $e) {
return [];
}
}
/**
* {@inheritdoc}
*/
public function getLocales()
{
try {
return $this->localeProvider->getLocales();
} catch (MissingResourceException $e) {
return [];
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
/**
* Gives access to region-related ICU data.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface RegionBundleInterface extends ResourceBundleInterface
{
/**
* Returns the name of a country.
*
* @param string $country A country code (e.g. "US")
* @param string $displayLocale Optional. The locale to return the name in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string|null The name of the country or NULL if not found
*/
public function getCountryName($country, $displayLocale = null);
/**
* Returns the names of all known countries.
*
* @param string $displayLocale Optional. The locale to return the names in
* Defaults to {@link \Locale::getDefault()}.
*
* @return string[] A list of country names indexed by country codes
*/
public function getCountryNames($displayLocale = null);
}

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Intl\ResourceBundle;
/**
* Gives access to ICU data.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface ResourceBundleInterface
{
/**
* Returns the list of locales that this bundle supports.
*
* @return string[] A list of locale codes
*/
public function getLocales();
}