Hack book of
Unfortunately, the documentation of this library has not
been written yet. However, the
README.md file may contain
enough information to help you. This document is an extract of the
Sorry for this inconvenience. Be ensured we are working hard to fix this.
This library allows to get the informations of the locale from the system, the HTTP client or something else.
We propose a quick overview to get the locale and related informations about an HTTP client. Next, we will see the other localizers.
Locale from an HTTP client
To get the locale from an HTTP client, we will use the
Hoa\Locale\Localizer\Http localizer. Then, we will print the result of the
following interesting methods:
getLanguageto get the language,
getScriptto get the script,
getRegionto get the region,
getVariantsto get variants of the locale.
$locale = new Hoa\Locale(new Hoa\Locale\Localizer\Http()); echo 'language : ', $locale->getLanguage(), "\n", 'script : ', $locale->getScript(), "\n", 'region : ', $locale->getRegion(), "\n", 'variant : ', implode(', ', $locale->getVariants()), "\n";
For example, with the
Accept-Language HTTP header set to
zh-Hant-TW-xy-ab-123, we will have:
language : zh script : Hant region : TW variant : xy, ab, 123
So far, we also have the
Hoa\Locale\Localizer\System to get the locale
informations from the system and
Hoa\Locale\Localizer\Coerce to get them from
an arbitrary locale representation.
An error or a suggestion about the documentation? Contributions are welcome!