Android 本地化值-** 文件夹名称 [英] Android localization values-** folder names

查看:26
本文介绍了Android 本地化值-** 文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了几个相互冲突的表格,它们显示了本地化以及它们应该采用什么名称

I have seen several conflicting tables that show localizations and what names they should take

他们中的很多人建议每个国家/地区都有语言版本,这很好,对于英语、西班牙语和中文等语言,我可以选择在其中创建一个 values-en 文件夹或 values-en_US 文件夹,如果我想让它更具体

A lot of them suggest that there are versions of the language for each country, which is fine, for languages like English, Spanish and Chinese, where I can choose to make a values-en folder or a values-en_US folder if I want to make it more specific

但是像希腊语这样的其他一些语言有一个语言环境名称 el_GR ,我可以只创建一个文件夹名称 values-el 还是必须是 values-el_GR

but some other languages like greek have a locale name el_GR , can I just make a folder names values-el or does it HAVE to be values-el_GR

这只是一个例子,我不相信我读过的表格,android 开发者指南几乎没有列出可用的语言环境

thats just an example and I don't trust the tables I have read, and the android developer guide does not nearly list the available locales

推荐答案

Android字符串文件的文件夹名称格式如下:

The folder name of Android string files is formatted as the following:

  • 没有区域变体:values-[locale]
  • 带有区域变体:values-[locale]-r[region]
  • 例如:values-envalues-en-rGBvalues-el-rGR.

在您的情况下,您只需要为希腊语翻译创建一个文件夹values-el,为特定国家/地区的希腊语翻译创建一个values-el-rGR.

In your case, you just need to create a folder values-el for the Greek translation, and values-el-rGR for the country-specific Greek translation.

此外,您还可以利用 Android 中的资源回退机制,允许在本地进一步翻译特定的字符串.

Also, you can make use of the resources fallback mechanism in Android, to allow particular strings to be further translated locally.

例如,假设您有一个名为R.string.title"的字符串并且语言环境是el-GR",Android 将通过搜索以下文件来查找R.string.title"的值顺序:

For example, suppose you have a string called "R.string.title" and the locale is ‘el-GR’, Android will look for a value of "R.string.title" by searching the files in the following order:

  • res/values-el-rGR/strings.xml
  • res/values-el/strings.xml
  • res/values/strings.xml

因此,您可以将国家特定的翻译放在 res/values-el-rGR/strings.xml 中,然后让 res/values-el/strings.xml 存储一般翻译.

Therefore, you can just put the country-specific translation inside the res/values-el-rGR/strings.xml, and let the res/values-el/strings.xml stores the general translations.

利用这种回退机制,可以避免在不同语言文件中复制字符串.

It can avoid duplicating your strings in different language files by utilizing this fallback mechanism.

这篇关于Android 本地化值-** 文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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