This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Intl/Locale.php

51 lines
1.1 KiB
PHP
Raw Normal View History

<?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;
/**
* Provides access to locale-related data.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @internal
*/
final class Locale extends \Locale
{
/**
* Returns the fallback locale for a given locale, if any
*
* @param string $locale The ICU locale code to find the fallback for.
*
* @return string|null The ICU locale code of the fallback locale, or null
* if no fallback exists
*/
public static function getFallback($locale)
{
if (false === $pos = strrpos($locale, '_')) {
if ('root' === $locale) {
return;
}
return 'root';
}
return substr($locale, 0, $pos);
}
/**
* This class must not be instantiated.
*/
2014-09-21 19:53:12 +01:00
private function __construct()
{
}
}