设置语言环境编程语言、环境

2023-09-11 11:28:58 作者:﹏有一种格调叫我行我素╮

我的应用程序支持3(很快4)语言。由于一些语言环境是非常相似的,我想给用户选择改变区域设置在我的应用程序,比如一个意大利人可能preFER西班牙语过英语。

My app supports 3 (soon 4) languages. Since several locales are quite similar I'd like to give the user the option to change locale in my application, for instance an Italian person might prefer Spanish over English.

有没有办法为用户可用应用程序的语言环境中进行选择,然后改一下语言环境中使用?我不认为这是一个问题,设置区域设置每一项活动,因为它是一个简单的任务,在基类来执行。

Is there a way for the user to select among the locales that are available for the application and then change what locale is used? I don't see it as a problem to set locale for each Activity since it is a simple task to perform in a base class.

推荐答案

希望这有助于(在onResume):

Hope this help(in onResume):

Locale locale = new Locale("ru");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
      getBaseContext().getResources().getDisplayMetrics());
 
精彩推荐
图片推荐