简体   繁体   中英

Can I use Google Translator to enable multi language in Android app?

I'm working on an Android app. I need to make it available in many languages. Can we use Google Translate Plugin or translate API to get this work ?

Please check this link : https://www.w3schools.com/howto/tryit.asp?filename=tryhow_google_translate

You can see there's a drop down to get all the language list. Can I use something like this in my Android app ?

If I can't use a this method, what's the best way to enable multi-language feature in an Android app ?

Every android app has a resource value "strings" (a list of values for string variables) to provide different languages.

<resources>
<string name="home_act_bottom_bar_home_item">Shop</string>
<string name="home_act_bottom_bar_cont_item">Contacts</string>
<string name="home_act_bottom_bar_cart_item">Cart</string>
</resources>

The application must have a new string res file for each language. When the application is launched, the OS detects current system language which was chosen by user in android settings and then try to find this language in res files. If the file we need exists (for example Russian) it will be used, if not - the system will start application with default strings res file(often English). You certainly may use different web-services to translate you "Strings" after application was launched, but it will need time, will make user experience worth (user will have to wait for translation and UI update), will make your code very complex. I suggest you to translate your App beforehand, and put translations to according string res files, it will make your app fast and code not so complex.

You can read official docs here: https://developer.android.com/training/basics/supporting-devices/languages

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM