Close search
Hoa

Hack book of Hoa\Locale

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 README.md file.
Sorry for this inconvenience. Be ensured we are working hard to fix this.

Help on IRC Help on Gitter Documentation Board

This library allows to get the informations of the locale from the system, the HTTP client or something else.

Learn more.

Quick usage

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:

Thus:

$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

Other localizers

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!

Comments

menu