forked from finddreams/AndroidMultiLanguage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/finddreams/AndroidMultiLa…
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# AndroidMultiLanguage | ||
完美实现Android的多语言切换,国际化 | ||
应该是WebView在使用过程中会设置语言 , 比如说你在中国打开Facebook的网站 , 你的网页就是中文的 , 如果是美国就是英文的 , 这可能就是原因 . | ||
|
||
|
||
在使用到WebView的页面的onPause中 , 重新设置语言. | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
Resources resources = getResources(); | ||
Configuration configuration = resources.getConfiguration(); | ||
DisplayMetrics displayMetrics = resources.getDisplayMetrics(); | ||
if (isChina) { | ||
configuration.locale = Locale.CHINA; | ||
} else { | ||
configuration.locale = Locale.ENGLISH; | ||
} | ||
resources.updateConfiguration(configuration, displayMetrics); | ||
} |