如何实现Android l10n? [英] How to implement Android l10n ?

查看:63
本文介绍了如何实现Android l10n?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 如何实现Android系统l10n?德语已经是l10n.Android和Linux在实现系统本地化方面有何不同?
  2. 实施Android l10n的操作过程是什么?
  3. 实现Android系统本地化需要什么?例如Unicode UTF8,字符集或其他?

推荐答案

Android中的本地化是本机功能,您需要了解的是如何告诉android"在何处选择根据设置的语言翻译的单词在运行您的应用程序的设备上.

Localization in Android is a native function, what you have to understand is how to "tell android" where to pick the words translated based on the Language that is set on the device that is running your application.

1..在为Android开发应用程序时,请避免对字符串值进行硬编码",并始终使用位于 res/values 文件夹.在该文件中,使用 标记输入应用程序中使用的每个字符串:

1. When developing an application for Android avoid "hardcoding" the string values and always use the strings.xml file located in the res/values folder. In that file enter every string used in your application using the tag:

<string name="app_title">Super App</string>

2..从Java端使用方法 getString()在任何地方使用此字符串资源,此方法将要获取的项的ID用作参数. :

2. From the java side use this string resources from anywhere with the method getString(), this method receives as parameter the id of the item you want to get:

getString(R.string.app_title) 

3..定义了您的应用将使用的每个字符串后,只需复制 strings.xml 文件并将其粘贴到与应用程序相同级别的新文件夹中即可. res/values文件夹,但根据您要添加的新语言将其命名(请阅读

3. Once you have defined every string your app will use, just copy the strings.xml file and paste it in a new folder at the same level of the res/values folder but name it according to the new language you want to add (Read this)

4.:最后,将每个文件夹中的每个字符串翻译成正确的语言,但保持每个字符串的ID不变,只是更改其内容:

4. Finally, translate every string in each folder to the proper language but keeping the same ids of every string, just changing its content:

res/values-EN/strings.xml
<string name="app_title">Best Application Ever!</string>

res/values-ES/strings.xml
<string name="app_title">La Mejor Aplicación!</string>

res/values-FR/strings.xml
<string name="app_title">Meilleure Application Jamais!</string>

这篇关于如何实现Android l10n?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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