sergmoro1 / yii2-ru-kit
Set of behaviors used for Russian language.
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-12-29 00:06:03 UTC
README
Russian months for full date. Title transliteration to slug.
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist sergmoro1/yii2-ru-kit
or add
"sergmoro1/yii2-ru-kit": "~1.1"
to the require section of your composer.json.
Usage
For example common\models\Post.php
use sergmoro1\rukit\FullDate; use sergmoro1\rukit\Translit; class Post extends ActiveRecord { ... public function behaviors() { return [ ['class' => FullDate::className()], ['class' => Translit::className()], ]; } ... // Translit public function beforeSave($insert) { if(parent::beforeSave($insert)) { $this->translit(); return true; } else return false; }
in a view
<?= $model->fullDate('created_at'); // ru-RU -> 21 Фев 2018 ?>
only month and year
<?= $model->fullDate('created_at', 'M Y'); // en-US -> Feb 2018 ?>
full month, day and year.
<?= $model->fullDate('created_at', 'F d из t, Y (e)'); // ru-Ru -> Февраль 13 из 28, 2018 (UTC) ?>