多语言和multitheme在同一时间 [英] Multilanguage and multitheme at same time

查看:127
本文介绍了多语言和multitheme在同一时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有多语言支持的应用程序 - 成功(使用的 / RES /值的**方式)。然后,我想用全息和下降沿传统设备(2.3 *为例)使用默认的(使用的 / RES /值-V11 的方式)。

I'm developing an app that has multilanguage support (using the /res/values-** way) with success. Then I want to use Holo and falling legacy devices (2.3.* for example) to use the default one (using the /res/values-v11 way).

所以,我结束了一个与此相似的结构(没有语言之一是EN,默认):

So, I end up with a structure similar to this one (the one without language is EN, as default):


  • / RES /值

  • / RES /值-V11

  • / RES /值德

  • / RES /值-DE-V11

  • / RES /值-ES

  • / RES /值-ES-V11

......其中每一个我有以下几点:

... where in each one I have the following:


  • 的strings.xml

  • 的themes.xml

...其中的的strings.xml 是本地化的文本被定义,和的themes.xml 的有:

... where strings.xml is where the localised text are defined, and themes.xml has:

有关的非V11 的目录中(传统设备)

For non-v11 directories (legacy devices)

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="MyTheme" parent="@android:style/Theme">
        <!-- Any customizations for your app running on pre-3.0 devices here -->
    </style>
</resources>

有关的 -v11 的目录(+3.0设备)

For -v11 directories (+3.0 devices)

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="MyTheme" parent="@android:style/Theme.Holo">
        <!-- Any customizations for your app running on devices with Theme.Holo here -->
    </style>
</resources>

记住这个属性添加到应用程序标签上的Andr​​oidManifest.xml

Remembering to add this attribute into the application tag on AndroidManifest.xml

android:theme   ="@style/MyTheme"

这是工作在所有语言和所有设备,电流和传统,以正确的主题采摘和一切。经测试,在几个物理设备。

This is working in all languages and all devices, current and legacy, with correct theme picking and everything. Tested in several physical devices.

因此,问题:

难道你不认为这在很大程度上维护?我的意思是,我们对它们是完全相同的每一种语言2 string.xml文件,但每一个新的文本,我们必须填写两次,增加了拼写错误的风险。如果你有同样的情况的 analytics.xml styles.xml 的,里面...

Don't you think that this is heavily maintainable? I mean, then we have 2 string.xml files for every language which are exactly identical, but for every new text we have to fill it twice, increasing the risk of typos. The same happens if you have analytics.xml, styles.xml, ... inside

有使用Android中处理这么好的语言的的strings.xml 的,有没有其他的解决办法有一个更好的方式该工作multitheme和多语言?

Having the language handling so nice in Android using strings.xml, is there any other workaround to have this working multitheme and multilanguage in a nicer way?

感谢您。

推荐答案

我不知道为什么你需要像

I'm not sure why do you need something like

values-de-v11

我只想用这样的:

I would just use something like this:

values
values-de
values-fr
values-es
values-cat
...

和把与每一个翻译文件的strings.xml里面。
在另一方面,你还可以添加文件夹:

And put inside every strings.xml file with the translation. On the other hand you can also add the folders:

values
values-v11

和里面你可以添加你的主题。

And inside you can add your themes.

文件夹值应同时具有默认语言(通常是英文),无全息的设备后备主题文件中的strings.xml。

The folder values should have both the strings.xml for the default language (usually english) and the fallback theme file for devices without holo.

您可以检查所有possibilites文档中:

You can check all the possibilites in the documentation:

<一个href=\"http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources\" rel=\"nofollow\">http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

这篇关于多语言和multitheme在同一时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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