0

Hello guys first excuse me for poor language. I am going to build web page with multiple languages is there any way to get texts belong to device language?. Thank you.

Monder
  • 1
  • you could change the `accepted-language` header in your webview to the one you need (read it from the system) http://stackoverflow.com/questions/7610790/add-custom-headers-to-webview-resource-requests-android – A.S. Mar 03 '15 at 15:04

1 Answers1

0

Use this code to get the current language selected in the Android device

Locale.getDefault().getLanguage()        ---> en     
Locale.getDefault().getISO3Language()    ---> eng
Locale.getDefault().getCountry()         ---> US
Locale.getDefault().getISO3Country()     ---> USA
Locale.getDefault().toString()           ---> en_US
Locale.getDefault().getDisplayLanguage() ---> English
Locale.getDefault().getDisplayCountry()  ---> United States
Locale.getDefault().getDisplayName()     ---> English (United States)

To load the language dependent URL you can set the proper url to you webview like this.

String mUrl = "http://example.com/" + Locale.getDefault().getLanguage() + ".html"

WebView vw = (WebView) v.findViewById(R.id.loup_webview);
vw.setWebViewClient(new WebViewClient());
vw.loadUrl(mUrl);