mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-04 14:34:49 +01:00
Fixes #2079:
- i18n now falls back to `en` from `en-US` if message translation isn't found - View now falls back to `en` from `en-US` if file not found - Default `sourceLanguage` and `language` are now `en`
This commit is contained in:
@@ -43,8 +43,8 @@ class BaseFileHelper
|
||||
* a file with the same name will be looked for under the subdirectory
|
||||
* whose name is the same as the language code. For example, given the file "path/to/view.php"
|
||||
* and language code "zh_CN", the localized file will be looked for as
|
||||
* "path/to/zh_CN/view.php". If the file is not found, the original file
|
||||
* will be returned.
|
||||
* "path/to/zh_CN/view.php". If the file is not found, it will try a fallback with just a language code that is
|
||||
* "zh" i.e. "path/to/zh/view.php". If it is not found as well the original file will be returned.
|
||||
*
|
||||
* If the target and the source language codes are the same,
|
||||
* the original file will be returned.
|
||||
@@ -69,7 +69,16 @@ class BaseFileHelper
|
||||
return $file;
|
||||
}
|
||||
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . basename($file);
|
||||
return is_file($desiredFile) ? $desiredFile : $file;
|
||||
if (is_file($desiredFile)) {
|
||||
return $desiredFile;
|
||||
} else {
|
||||
$language = substr($language, 0, 2);
|
||||
if ($language === $sourceLanguage) {
|
||||
return $file;
|
||||
}
|
||||
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . basename($file);
|
||||
return is_file($desiredFile) ? $desiredFile : $file;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user