没有本地化Android的多语言支持 [英] Android multi language support without localization

查看:201
本文介绍了没有本地化Android的多语言支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我工作的一个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>

希望这会帮助你。

这篇关于没有本地化Android的多语言支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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