多语言和multitheme在同一时间

编程入门 行业动态 更新时间:2024-10-11 23:23:58
本文介绍了多语言和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:

developer.android/guide/topics/resources/providing-resources.html#AlternativeResources

更多推荐

多语言和multitheme在同一时间

本文发布于:2023-11-24 00:29:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623316.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多语言   时间   在同一   multitheme

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!