Rizwan
Rizwan

Reputation: 95

Change Default Language from Chinese to English

I have cloned Android WebView code https://github.com/AlexTam930/uploadimage the app is working but when i click on choose file, the option opens in chinese language enter image description here

I am new to android, trying to convert a website to AndroidApp through WebView.

in my source code where will i find the language change code??

Upvotes: 0

Views: 840

Answers (3)

Sweeper
Sweeper

Reputation: 272035

In MainActivity.java, line 169-171, there is this code:

    alertDialog.setTitle("请选择操作");
    // gallery, camera.
    String[] options = {"相册", "拍照"};

Replace the Chinese with English translations and you are done:

    alertDialog.setTitle("Please select an operation:");
    // gallery, camera.
    String[] options = {"Photo Album", "Camera"};

There are also other strings in MainActivity.java. I will provide a translation here:

Line 180, 196, 205:

请去"设置"中开启本应用的图片媒体访问权限 -> Please go to "Settings" to allow this app to access your photo album.

Line 215:

请去"设置"中开启本应用的相机权限 -> Please go to "Settings" to allow this app to access the camera.

Line 231:

请去"设置"中开启本应用的相机和图片媒体访问权限 -> Please go to "Settings" to allow this app to access the camera and the photo album.

Line 327:

String strMessage = "请允许使用\"" + permissionsMsg.substring(1).toString() + "\"权限, 以正常使用APP的所有功能.";

This line is basically creating a string that says "Please allow the access of XXX, so as to be able to use all the features of this app", where XXX is the string permissionMsg, which is constructed using the if statements a few lines before. This uses the strings in strings.xml, so you should probably go there and replace them with translations as well.

Upvotes: 2

Aslami.dev
Aslami.dev

Reputation: 1030

you can get android phone language from setting and send it by post request to your web and change your web language

to get current language in android ,use this:

Locale.getDefault().getDisplayLanguage();

Upvotes: 0

Dipendra Sharma
Dipendra Sharma

Reputation: 2640

Please check once git cloned code. There are some String resources with Chineses lang.

<resources>
    <string name="app_name">UploadImage</string>

    <string name="permission_camera">摄像头</string>
    <string name="permission_storage">文件</string>
    <string name="permission_accounts">信息</string>
    <string name="permission_phone">状态</string>
    <string name="permission_location">定位</string>
    <string name="permission_audio">录音</string>

</resources>

You can do one thing copy those strings and Translate those accordingly.

<resources>
    <string name="app_name">UploadImage</string>

    <string name="permission_camera">Camera</string>
    <string name="permission_storage">File</string>
    <string name="permission_accounts">Information</string>
    <string name="permission_phone">Status</string>
    <string name="permission_location">Positioning</string>
    <string name="permission_audio">Recording</string>

</resources>

Also, check if there are some string added in Java Code.

Upvotes: 2

Related Questions