mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-26 03:30:32 +08:00
Fixes #5164: Added Inlfector::$transliterator that can be used to customize intl transliteration
This commit is contained in:
committed by
Alexander Makarov
parent
df99195106
commit
2eda2725d0
@@ -220,6 +220,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #5117: Added `beforeFilter` and `afterFilter` JS events to `GridView` (kartik-v)
|
||||
- Enh #5124: Added support to prevent duplicated form submission when using `ActiveForm` (qiangxue)
|
||||
- Enh #5131: Added `$autoRenew` parameter to `yii\web\User::getIdentity()` (qiangxue)
|
||||
- Enh #5164: Added `Inlfector::$transliterator` that can be used to customize intl transliteration (zinzinday)
|
||||
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
|
||||
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
|
||||
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
|
||||
|
||||
@@ -231,7 +231,12 @@ class BaseInflector
|
||||
'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th',
|
||||
'ÿ' => 'y',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var mixed Either a [[Transliterator]] or a string from which a [[Transliterator]]
|
||||
* can be built for transliteration used by [[slug()]] when intl is available.
|
||||
* @see http://php.net/manual/en/transliterator.transliterate.php
|
||||
*/
|
||||
public static $transliterator = 'Any-Latin; NFKD';
|
||||
|
||||
/**
|
||||
* Converts a word to its plural form.
|
||||
@@ -437,7 +442,7 @@ class BaseInflector
|
||||
protected static function transliterate($string)
|
||||
{
|
||||
if (static::hasIntl()) {
|
||||
return transliterator_transliterate('Any-Latin; NFKD', $string);
|
||||
return transliterator_transliterate(static::$transliterator, $string);
|
||||
} else {
|
||||
return str_replace(array_keys(static::$transliteration), static::$transliteration, $string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user