没有本地化Android的多语言支持多语言、Android

2023-09-04 06:08:02 作者:浪女无家

你好我工作的一个Android项目。

Hi I'm working on a android project.

我要提供的applciation多语言支持。 我研究这件事,但是我发现几乎所有的本地化。

I want to provide multiple language support for the applciation. I researched about it but I found almost everything with localization.

有没有办法做到这一点不使用本土化?

Is there any way to do this without using localization?

我的preference使用语言支持的本地化或支持的版本。

My preference is using language support for localization or supported versions.

我的意思是用户可以切换语言的应用程序。

I mean user can switch the languages in application.

我能做到这一点有多个值的文件吗?

Can I do this with multiple value files?

推荐答案

使用此选项可以更改由code语言 -

Use this to change the language by code--

 Locale locale = new Locale("en_US");
 Locale.setDefault(locale);
 Configuration config = new Configuration();
 config.locale = locale;
 context.getApplicationContext().getResources().updateConfiguration(config, null);

编写语言的国家code代替任何一种语言,你想用en_US......像日本 - Ja_JP表示对于阿拉伯语 - AR或检查该链接,$ C $了C国家 -

Write the countrycode of language in place of "en_US" whatever language you want...like for japanese--"ja_JP" For Arabic--"ar" or check this link for code of country--

HTTP://$c$c.google.com/原料药/的iGoogle /文档/ i18n.html

,并在 RES /值-JA 日本或 RES /值-AR 文件夹为阿拉伯语。

And make a folder in res/values-ja for japanese or res/values-ar for arabic..

和做出的 string.xml 文件,并把任何你想要在你的版面语言.. 这将获取从值文件夹的默认语言,否则你想手工那么它会读取来自外部文件夹值-AR等一样...

And make string.xml file And put the languages whatever you want on your layout.. It will fetch the default language from values folder otherwise you want it manually then it will fetch from your external folder values-ar etc. like...

它的RE /值-AR阿拉伯语例如 -

Its example of res/values-ar for arabic--

<?xml version="1.0" encoding="UTF-8"?>
  <resources>
     <string name="spinner_label">تصفية حسب</string>
     <string name="app_name">2011 فرق</string> 
     <string name="search">بحث :</string>
  </resource>

希望这会帮助你。