[Intl] Made the $locale parameter optional in the bundle interfaces
This commit is contained in:
parent
b9e9cb27b9
commit
2cd1be8df3
@ -300,7 +300,7 @@ class StubNumberFormatter
|
|||||||
return $this->format($value);
|
return $this->format($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$symbol = Intl::getCurrencyBundle()->getCurrencySymbol('en', $currency);
|
$symbol = Intl::getCurrencyBundle()->getCurrencySymbol($currency, 'en');
|
||||||
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
|
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
|
||||||
|
|
||||||
$value = $this->roundCurrency($value, $currency);
|
$value = $this->roundCurrency($value, $currency);
|
||||||
|
@ -55,13 +55,13 @@ Numbers can be formatted with the [`\NumberFormatter`] [3] class. The following
|
|||||||
methods are supported. All other methods are not supported and will throw an
|
methods are supported. All other methods are not supported and will throw an
|
||||||
exception when used.
|
exception when used.
|
||||||
|
|
||||||
##### __construct($locale = 'en', $style = null, $pattern = null)
|
##### __construct($locale = $style = null, $pattern = null)
|
||||||
|
|
||||||
The only supported locale is "en". The supported styles are
|
The only supported locale is "en". The supported styles are
|
||||||
`\NumberFormatter::DECIMAL` and `\NumberFormatter::CURRENCY`. The argument
|
`\NumberFormatter::DECIMAL` and `\NumberFormatter::CURRENCY`. The argument
|
||||||
`$pattern` may not be used.
|
`$pattern` may not be used.
|
||||||
|
|
||||||
##### ::create($locale = 'en', $style = null, $pattern = null)
|
##### ::create($locale = $style = null, $pattern = null)
|
||||||
|
|
||||||
See `__construct()`.
|
See `__construct()`.
|
||||||
|
|
||||||
@ -115,19 +115,19 @@ Languages and Scripts
|
|||||||
The translations of language and script names can be found in the language
|
The translations of language and script names can be found in the language
|
||||||
bundle.
|
bundle.
|
||||||
|
|
||||||
$languages = Intl::getLanguageBundle()->getLanguageNames('en');
|
$languages = Intl::getLanguageBundle()->getLanguageNames();
|
||||||
// => array('ab' => 'Abkhazian', ...)
|
// => array('ab' => 'Abkhazian', ...)
|
||||||
|
|
||||||
$language = Intl::getLanguageBundle()->getLanguageName('en', 'de');
|
$language = Intl::getLanguageBundle()->getLanguageName('de');
|
||||||
// => 'German'
|
// => 'German'
|
||||||
|
|
||||||
$language = Intl::getLanguageBundle()->getLanguageName('en', 'de', 'AT);
|
$language = Intl::getLanguageBundle()->getLanguageName('de', 'AT);
|
||||||
// => 'Austrian German'
|
// => 'Austrian German'
|
||||||
|
|
||||||
$scripts = Intl::getLanguageBundle()->getScriptNames('en');
|
$scripts = Intl::getLanguageBundle()->getScriptNames();
|
||||||
// => array('Arab' => 'Arabic', ...)
|
// => array('Arab' => 'Arabic', ...)
|
||||||
|
|
||||||
$script = Intl::getLanguageBundle()->getScriptName('en', 'Hans');
|
$script = Intl::getLanguageBundle()->getScriptName('Hans');
|
||||||
// => 'Simplified'
|
// => 'Simplified'
|
||||||
|
|
||||||
Countries
|
Countries
|
||||||
@ -135,10 +135,10 @@ Countries
|
|||||||
|
|
||||||
The translations of country names can be found in the region bundle.
|
The translations of country names can be found in the region bundle.
|
||||||
|
|
||||||
$countries = Intl::getRegionBundle()->getCountryNames('en');
|
$countries = Intl::getRegionBundle()->getCountryNames();
|
||||||
// => array('AF' => 'Afghanistan', ...)
|
// => array('AF' => 'Afghanistan', ...)
|
||||||
|
|
||||||
$country = Intl::getRegionBundle()->getCountryName('en', 'GB');
|
$country = Intl::getRegionBundle()->getCountryName('GB');
|
||||||
// => 'United Kingdom'
|
// => 'United Kingdom'
|
||||||
|
|
||||||
Locales
|
Locales
|
||||||
@ -146,10 +146,10 @@ Locales
|
|||||||
|
|
||||||
The translations of locale names can be found in the locale bundle.
|
The translations of locale names can be found in the locale bundle.
|
||||||
|
|
||||||
$locales = Intl::getLocaleBundle()->getLocaleNames('en');
|
$locales = Intl::getLocaleBundle()->getLocaleNames();
|
||||||
// => array('af' => 'Afrikaans', ...)
|
// => array('af' => 'Afrikaans', ...)
|
||||||
|
|
||||||
$locale = Intl::getLocaleBundle()->getLocaleName('en', 'zh_Hans_MO');
|
$locale = Intl::getLocaleBundle()->getLocaleName('zh_Hans_MO');
|
||||||
// => 'Chinese (Simplified, Macau SAR China)'
|
// => 'Chinese (Simplified, Macau SAR China)'
|
||||||
|
|
||||||
Currencies
|
Currencies
|
||||||
@ -158,13 +158,13 @@ Currencies
|
|||||||
The translations of currency names and other currency-related information can
|
The translations of currency names and other currency-related information can
|
||||||
be found in the currency bundle.
|
be found in the currency bundle.
|
||||||
|
|
||||||
$currencies = Intl::getCurrencyBundle()->getCurrencyNames('en');
|
$currencies = Intl::getCurrencyBundle()->getCurrencyNames();
|
||||||
// => array('AFN' => 'Afghan Afghani', ...)
|
// => array('AFN' => 'Afghan Afghani', ...)
|
||||||
|
|
||||||
$currency = Intl::getCurrencyBundle()->getCurrencyNames('en', 'INR');
|
$currency = Intl::getCurrencyBundle()->getCurrencyNames('INR');
|
||||||
// => 'Indian Rupee'
|
// => 'Indian Rupee'
|
||||||
|
|
||||||
$symbol = Intl::getCurrencyBundle()->getCurrencyNames('en', 'INR');
|
$symbol = Intl::getCurrencyBundle()->getCurrencyNames('INR');
|
||||||
// => '₹'
|
// => '₹'
|
||||||
|
|
||||||
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits('INR');
|
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits('INR');
|
||||||
|
@ -29,24 +29,36 @@ class CurrencyBundle extends AbstractBundle implements CurrencyBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCurrencySymbol($locale, $currency)
|
public function getCurrencySymbol($currency, $locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_SYMBOL));
|
return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_SYMBOL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCurrencyName($locale, $currency)
|
public function getCurrencyName($currency, $locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_NAME));
|
return $this->readEntry($locale, array('Currencies', $currency, static::INDEX_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCurrencyNames($locale)
|
public function getCurrencyNames($locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === ($currencies = $this->readEntry($locale, array('Currencies')))) {
|
if (null === ($currencies = $this->readEntry($locale, array('Currencies')))) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -21,31 +21,34 @@ interface CurrencyBundleInterface extends ResourceBundleInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the symbol used for a currency.
|
* Returns the symbol used for a currency.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the result in.
|
|
||||||
* @param string $currency A currency code (e.g. "EUR").
|
* @param string $currency A currency code (e.g. "EUR").
|
||||||
|
* @param string $locale Optional. The locale to return the result in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string|null The currency symbol or NULL if not found.
|
* @return string|null The currency symbol or NULL if not found.
|
||||||
*/
|
*/
|
||||||
public function getCurrencySymbol($locale, $currency);
|
public function getCurrencySymbol($currency, $locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of a currency.
|
* Returns the name of a currency.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the name in.
|
|
||||||
* @param string $currency A currency code (e.g. "EUR").
|
* @param string $currency A currency code (e.g. "EUR").
|
||||||
|
* @param string $locale Optional. The locale to return the name in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string|null The name of the currency or NULL if not found.
|
* @return string|null The name of the currency or NULL if not found.
|
||||||
*/
|
*/
|
||||||
public function getCurrencyName($locale, $currency);
|
public function getCurrencyName($currency, $locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the names of all known currencies.
|
* Returns the names of all known currencies.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the names in.
|
* @param string $locale Optional. The locale to return the names in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string[] A list of currency names indexed by currency codes.
|
* @return string[] A list of currency names indexed by currency codes.
|
||||||
*/
|
*/
|
||||||
public function getCurrencyNames($locale);
|
public function getCurrencyNames($locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of digits after the comma of a currency.
|
* Returns the number of digits after the comma of a currency.
|
||||||
|
@ -21,8 +21,12 @@ class LanguageBundle extends AbstractBundle implements LanguageBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getLanguageName($locale, $lang, $region = null)
|
public function getLanguageName($lang, $region = null, $locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
|
if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@ -39,8 +43,12 @@ class LanguageBundle extends AbstractBundle implements LanguageBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getLanguageNames($locale)
|
public function getLanguageNames($locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
|
if (null === ($languages = $this->readEntry($locale, array('Languages')))) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@ -55,8 +63,12 @@ class LanguageBundle extends AbstractBundle implements LanguageBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getScriptName($locale, $script, $lang = null)
|
public function getScriptName($script, $lang = null, $locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
$data = $this->read($locale);
|
$data = $this->read($locale);
|
||||||
|
|
||||||
// Some languages are translated together with their script,
|
// Some languages are translated together with their script,
|
||||||
@ -84,8 +96,12 @@ class LanguageBundle extends AbstractBundle implements LanguageBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getScriptNames($locale)
|
public function getScriptNames($locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === ($scripts = $this->readEntry($locale, array('Scripts')))) {
|
if (null === ($scripts = $this->readEntry($locale, array('Scripts')))) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -21,40 +21,44 @@ interface LanguageBundleInterface extends ResourceBundleInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the name of a language.
|
* Returns the name of a language.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the name in.
|
|
||||||
* @param string $lang A language code (e.g. "en").
|
* @param string $lang A language code (e.g. "en").
|
||||||
* @param string|null $region Optional. A region code (e.g. "US").
|
* @param string|null $region Optional. A region code (e.g. "US").
|
||||||
|
* @param string $locale Optional. The locale to return the name in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string|null The name of the language or NULL if not found.
|
* @return string|null The name of the language or NULL if not found.
|
||||||
*/
|
*/
|
||||||
public function getLanguageName($locale, $lang, $region = null);
|
public function getLanguageName($lang, $region = null, $locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the names of all known languages.
|
* Returns the names of all known languages.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the names in.
|
* @param string $locale Optional. The locale to return the names in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string[] A list of language names indexed by language codes.
|
* @return string[] A list of language names indexed by language codes.
|
||||||
*/
|
*/
|
||||||
public function getLanguageNames($locale);
|
public function getLanguageNames($locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of a script.
|
* Returns the name of a script.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the name in.
|
|
||||||
* @param string $script A script code (e.g. "Hans").
|
* @param string $script A script code (e.g. "Hans").
|
||||||
* @param string $lang Optional. A language code (e.g. "zh").
|
* @param string $lang Optional. A language code (e.g. "zh").
|
||||||
|
* @param string $locale Optional. The locale to return the name in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string|null The name of the script or NULL if not found.
|
* @return string|null The name of the script or NULL if not found.
|
||||||
*/
|
*/
|
||||||
public function getScriptName($locale, $script, $lang = null);
|
public function getScriptName($script, $lang = null, $locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the names of all known scripts.
|
* Returns the names of all known scripts.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the names in.
|
* @param string $locale Optional. The locale to return the names in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string[] A list of script names indexed by script codes.
|
* @return string[] A list of script names indexed by script codes.
|
||||||
*/
|
*/
|
||||||
public function getScriptNames($locale);
|
public function getScriptNames($locale = null);
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,24 @@ class LocaleBundle extends AbstractBundle implements LocaleBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getLocaleName($locale, $ofLocale)
|
public function getLocaleName($ofLocale, $locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->readEntry($locale, array('Locales', $ofLocale));
|
return $this->readEntry($locale, array('Locales', $ofLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getLocaleNames($locale)
|
public function getLocaleNames($locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === ($locales = $this->readEntry($locale, array('Locales')))) {
|
if (null === ($locales = $this->readEntry($locale, array('Locales')))) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,21 @@ interface LocaleBundleInterface extends ResourceBundleInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the name of a locale.
|
* Returns the name of a locale.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the name in.
|
|
||||||
* @param string $ofLocale The locale to return the name of (e.g. "de_AT").
|
* @param string $ofLocale The locale to return the name of (e.g. "de_AT").
|
||||||
|
* @param string $locale Optional. The locale to return the name in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string|null The name of the locale or NULL if not found.
|
* @return string|null The name of the locale or NULL if not found.
|
||||||
*/
|
*/
|
||||||
public function getLocaleName($locale, $ofLocale);
|
public function getLocaleName($ofLocale, $locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the names of all known locales.
|
* Returns the names of all known locales.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the name in.
|
* @param string $locale Optional. The locale to return the names in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string[] A list of locale names indexed by locale codes.
|
* @return string[] A list of locale names indexed by locale codes.
|
||||||
*/
|
*/
|
||||||
public function getLocaleNames($locale);
|
public function getLocaleNames($locale = null);
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,24 @@ class RegionBundle extends AbstractBundle implements RegionBundleInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCountryName($locale, $country)
|
public function getCountryName($country, $locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->readEntry($locale, array('Countries', $country));
|
return $this->readEntry($locale, array('Countries', $country));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getCountryNames($locale)
|
public function getCountryNames($locale = null)
|
||||||
{
|
{
|
||||||
|
if (null === $locale) {
|
||||||
|
$locale = \Locale::getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
if (null === ($countries = $this->readEntry($locale, array('Countries')))) {
|
if (null === ($countries = $this->readEntry($locale, array('Countries')))) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,21 @@ interface RegionBundleInterface extends ResourceBundleInterface
|
|||||||
/**
|
/**
|
||||||
* Returns the name of a country.
|
* Returns the name of a country.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the name in.
|
|
||||||
* @param string $country A country code (e.g. "US").
|
* @param string $country A country code (e.g. "US").
|
||||||
|
* @param string $locale Optional. The locale to return the name in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string|null The name of the country or NULL if not found.
|
* @return string|null The name of the country or NULL if not found.
|
||||||
*/
|
*/
|
||||||
public function getCountryName($locale, $country);
|
public function getCountryName($country, $locale = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the names of all known countries.
|
* Returns the names of all known countries.
|
||||||
*
|
*
|
||||||
* @param string $locale The locale to return the names in.
|
* @param string $locale Optional. The locale to return the names in.
|
||||||
|
* Defaults to {@link \Locale::getLocale()}.
|
||||||
*
|
*
|
||||||
* @return string[] A list of country names indexed by country codes.
|
* @return string[] A list of country names indexed by country codes.
|
||||||
*/
|
*/
|
||||||
public function getCountryNames($locale);
|
public function getCountryNames($locale = null);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class CurrencyBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 1))
|
->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 1))
|
||||||
->will($this->returnValue('€'));
|
->will($this->returnValue('€'));
|
||||||
|
|
||||||
$this->assertSame('€', $this->bundle->getCurrencySymbol('en', 'EUR'));
|
$this->assertSame('€', $this->bundle->getCurrencySymbol('EUR', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCurrencyName()
|
public function testGetCurrencyName()
|
||||||
@ -53,7 +53,7 @@ class CurrencyBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 0))
|
->with(self::RES_DIR, 'en', array('Currencies', 'EUR', 0))
|
||||||
->will($this->returnValue('Euro'));
|
->will($this->returnValue('Euro'));
|
||||||
|
|
||||||
$this->assertSame('Euro', $this->bundle->getCurrencyName('en', 'EUR'));
|
$this->assertSame('Euro', $this->bundle->getCurrencyName('EUR', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCurrencyNames()
|
public function testGetCurrencyNames()
|
||||||
|
@ -48,7 +48,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en', array('Languages'))
|
->with(self::RES_DIR, 'en', array('Languages'))
|
||||||
->will($this->returnValue($languages));
|
->will($this->returnValue($languages));
|
||||||
|
|
||||||
$this->assertSame('German', $this->bundle->getLanguageName('en', 'de'));
|
$this->assertSame('German', $this->bundle->getLanguageName('de', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLanguageNameWithRegion()
|
public function testGetLanguageNameWithRegion()
|
||||||
@ -64,7 +64,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en', array('Languages'))
|
->with(self::RES_DIR, 'en', array('Languages'))
|
||||||
->will($this->returnValue($languages));
|
->will($this->returnValue($languages));
|
||||||
|
|
||||||
$this->assertSame('British English', $this->bundle->getLanguageName('en', 'en', 'GB'));
|
$this->assertSame('British English', $this->bundle->getLanguageName('en', 'GB', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLanguageNameWithUntranslatedRegion()
|
public function testGetLanguageNameWithUntranslatedRegion()
|
||||||
@ -79,7 +79,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en', array('Languages'))
|
->with(self::RES_DIR, 'en', array('Languages'))
|
||||||
->will($this->returnValue($languages));
|
->will($this->returnValue($languages));
|
||||||
|
|
||||||
$this->assertSame('English', $this->bundle->getLanguageName('en', 'en', 'US'));
|
$this->assertSame('English', $this->bundle->getLanguageName('en', 'US', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLanguageNames()
|
public function testGetLanguageNames()
|
||||||
@ -115,7 +115,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en')
|
->with(self::RES_DIR, 'en')
|
||||||
->will($this->returnValue($data));
|
->will($this->returnValue($data));
|
||||||
|
|
||||||
$this->assertSame('latin', $this->bundle->getScriptName('en', 'Latn'));
|
$this->assertSame('latin', $this->bundle->getScriptName('Latn', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetScriptNameIncludedInLanguage()
|
public function testGetScriptNameIncludedInLanguage()
|
||||||
@ -138,7 +138,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue($data));
|
->will($this->returnValue($data));
|
||||||
|
|
||||||
// Null because the script is included in the language anyway
|
// Null because the script is included in the language anyway
|
||||||
$this->assertNull($this->bundle->getScriptName('en', 'Hans', 'zh'));
|
$this->assertNull($this->bundle->getScriptName('Hans', 'zh', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetScriptNameIncludedInLanguageInBraces()
|
public function testGetScriptNameIncludedInLanguageInBraces()
|
||||||
@ -160,7 +160,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en')
|
->with(self::RES_DIR, 'en')
|
||||||
->will($this->returnValue($data));
|
->will($this->returnValue($data));
|
||||||
|
|
||||||
$this->assertSame('simplified', $this->bundle->getScriptName('en', 'Hans', 'zh'));
|
$this->assertSame('simplified', $this->bundle->getScriptName('Hans', 'zh', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetScriptNameNoScriptsBlock()
|
public function testGetScriptNameNoScriptsBlock()
|
||||||
@ -177,7 +177,7 @@ class LanguageBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en')
|
->with(self::RES_DIR, 'en')
|
||||||
->will($this->returnValue($data));
|
->will($this->returnValue($data));
|
||||||
|
|
||||||
$this->assertNull($this->bundle->getScriptName('en', 'Latn'));
|
$this->assertNull($this->bundle->getScriptName('Latn', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetScriptNames()
|
public function testGetScriptNames()
|
||||||
|
@ -44,7 +44,7 @@ class LocaleBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue('German (Austria)'));
|
->will($this->returnValue('German (Austria)'));
|
||||||
|
|
||||||
|
|
||||||
$this->assertSame('German (Austria)', $this->bundle->getLocaleName('en', 'de_AT'));
|
$this->assertSame('German (Austria)', $this->bundle->getLocaleName('de_AT', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetLocaleNames()
|
public function testGetLocaleNames()
|
||||||
|
@ -43,7 +43,7 @@ class RegionBundleTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with(self::RES_DIR, 'en', array('Countries', 'AT'))
|
->with(self::RES_DIR, 'en', array('Countries', 'AT'))
|
||||||
->will($this->returnValue('Austria'));
|
->will($this->returnValue('Austria'));
|
||||||
|
|
||||||
$this->assertSame('Austria', $this->bundle->getCountryName('en', 'AT'));
|
$this->assertSame('Austria', $this->bundle->getCountryName('AT', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCountryNames()
|
public function testGetCountryNames()
|
||||||
|
Reference in New Issue
Block a user