phospr / locale
A simple PHP Locale Value Object
Installs: 1 988
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/php-invoker: ~1.1
- phpunit/phpunit: 4.0.*
This package is auto-updated.
Last update: 2024-11-06 10:43:40 UTC
README
Simple PHP Locale ValueObject
Usage
use Phospr\Locale;
echo Locale::fromString('en_US'); // en_US
echo Locale::fromCountrySlashLanguage('ca/fr'); // fr_CA
Formatting
Use:
%L
For uppercase language code%l
For lowercase language code%C
For uppercase country code%c
For lowercase country code
Note:
- any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \
- to get a
\
You will need to double escape (\\\
)
Examples:
echo Locale::fromString('se_FI')->format('%L_%c'); // SE_fi echo Locale::fromString('se_FI')->format('%C/%s'); // FI/se echo Locale::fromString('se_FI')->format('%c/%s'); // fi/se echo Locale::fromString('se_FI')->format('%c\\\%s'); // fi\se
Installation
composer require phospr/locale
Sources
Language data from http://stackoverflow.com/a/4900304
Country data from http://country.io/data/