ashrafakl / yii2-locale
The yii2-locale extension represents the data relevant to a locale such as countries, languages, and orientation.
Installs: 402
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- ext-intl: *
- yiisoft/yii2: ~2.0.5
This package is auto-updated.
Last update: 2025-05-15 05:11:01 UTC
README
Locale class represents the data relevant to a locale such as countries, languages, and orientation.
This class uses and depend on the PHP intl extension.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist ashrafakl/yii2-locale "~1.0.3"
or add
"ashrafakl/yii2-locale": "~1.0.3"
to the require section of your composer.json
file.
Usage
Once the extension is installed then add this to your application configuration:
<?php return [ // ... 'components' => [ // ... 'locale' => [ 'class'=> 'ashrafakl\localization\Locale', ], // ... ] ];
Public properties
Name | Description |
---|---|
bundlename | Path of ResourceBundle for which to get available locales, or empty string for default locales list http://php.net/manual/en/resourcebundle.locales.php |
Public methods
Name | Description |
---|---|
getCountries | Get Countries list |
getCountry | Get Country |
getRelativePrimaryLanguages | Get languages list relative to its locale |
getPrimaryLanguages | Get languages list |
getOrientation | Get characters orientation, which is either 'ltr' (left-to-right) or 'rtl' (right-to-left) |
Example
To get orientaion use the following code
<?= Yii::$app->locale->getOrientation() ?>