如何使用XML在Android的多语言应用程序? [英] How to create a multi-language app with XML in Android?

查看:148
本文介绍了如何使用XML在Android的多语言应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个多语言Android应用程序与三种语言:英语,阿拉伯语和波斯语

I want to create a multi-language Android application with three languages: English, Arabic and Persian language.

我必须在资产文件夹中创建三个XML文件,并解析这些文件,然后使用一个用于语言?

I must create three XML files in the assets folder and parse them all, then use one for the language?

请帮我解决我的问题?

推荐答案

您需要有不同的strings.xml来支持不同的汉语语言。

You need to have different strings.xml to support different langauges.

http://developer.android.com/training/basics/supporting-devices/languages.html

<一个href="http://stackoverflow.com/questions/7973023/what-is-the-list-of-supported-languages-locales-on-android">What是支持的语言列表/ Android上的语言环境?。

我不认为有波斯语言的支持。

I don't think there is support for persian language.

例如:

MyProject的/

MyProject/

res/
   values/
       strings.xml

   values-es/
       strings.xml

   values-fr/
       strings.xml

   values-ar/          // for arabic
       strings.xml     

西班牙

 <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="title">Mi Aplicación</string>
    <string name="hello_world">Hola Mundo!</string>
</resources>

在运行时,Android系统使用适当的一套基于当前为用户的设备设置区域设置字符串资源。

At runtime, the Android system uses the appropriate set of string resources based on the locale currently set for the user's device.

http://developer.android.com/guide/topics/resources/ localization.html

TextView textView = new TextView(this);
textView.setText(R.string.hello_world);

检查文档获取更多信息。

Check the doc for more info

http://developer.android.com/training/basics/supporting-devices/languages.html

这篇关于如何使用XML在Android的多语言应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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