From 82380a1ff582d4c5928504398a86dce27a5c51d9 Mon Sep 17 00:00:00 2001 From: deffyc Date: Fri, 17 Jun 2016 01:19:49 +0800 Subject: [PATCH] Update Data.php becourse of some reason,some languages has many forms in their history.eg:cn has zh and tw --- helpers/Data.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/helpers/Data.php b/helpers/Data.php index 1d054f3..57cbf52 100644 --- a/helpers/Data.php +++ b/helpers/Data.php @@ -25,6 +25,8 @@ public static function cache($key, $duration, $callable) public static function getLocale() { - return strtolower(substr(Yii::$app->language, 0, 2)); + $muti_lan_array=['zh-cn','zh-tw']; + $language=strtolower(trim(Yii::$app->language)); + return in_array($language,$muti_lan_array,false)?$language:substr($language, 0, 2); } -} \ No newline at end of file +}