根据手机语言运行不同的功能 [英] Run different functions depending on phone language

查看:277
本文介绍了根据手机语言运行不同的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的应用程序3种语言的支持。并根据什么语言的电话设置为使用我想我的应用程序来运行基于该功能。

I have support for 3 languages in my app. And depending on what language the phone is set to use I want my app to run a function based on that.

推荐答案

一般情况下最好的做法是不要用不同的code为不同的语言,只需要使用不同的资源。然而,如果你仍然需要它,你可以使用Locale类。
如果你希望得到您的设备选择的语言:

Generally best practice is not to use different code for different languages, just use different resources. However if you still need it you can use the Locale class. If you want to get the selected language of your device:

Locale.getDefault().getDisplayLanguage();

如果您有兴趣刚开ISO code(例如,用于if或switch语句)使用方法:

If you're interested in just getting the ISO code (e.g. for if or switch statements) use:

Locale.getDefault().getISO3Language();

这篇关于根据手机语言运行不同的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆