library locale
A simple PHP Locale Value Object
phospr/locale
A simple PHP Locale Value Object
- Monday, March 14, 2016
- by tomhv
- Repository
- 1 Watchers
- 1 Stars
- 1,073 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 3 Forks
- 0 Open issues
- 2 Versions
- 4 % Grown
Phospr\Locale
, (*1)
Simple PHP Locale ValueObject, (*2)
Usage
use Phospr\Locale;
echo Locale::fromString('en_US'); // en_US
echo Locale::fromCountrySlashLanguage('ca/fr'); // fr_CA
Use:, (*3)
-
%L
For uppercase language code
-
%l
For lowercase language code
-
%C
For uppercase country code
-
%c
For lowercase country code
Note:, (*4)
- any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \
- to get a
\
You will need to double escape ( \\\
)
Examples:, (*5)
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, (*6)
Country data from http://country.io/data/, (*7)
dev-master
9999999-dev
A simple PHP Locale Value Object
Sources
Download
MIT
The Requires
The Development Requires
by
Tom Haskins-Vaughan
v1.0.0
1.0.0.0
A simple PHP Locale Value Object
Sources
Download
MIT
The Requires
The Development Requires
by
Tom Haskins-Vaughan