Multi-language and multi-theme at the same time

I am developing an application that has multilingual support (using / res / values ​​- ** way) with success. Then I want to use Holo and drop legacy devices (e.g. 2.3. *), To use the standard default (using the path / res / values ​​-v11).

So, I get a structure similar to the one (by default - a language without EN):

  • / Res / values
  • / Res / value-v11
  • / Res / de values
  • / Res / values ​​de v11
  • / RES / value-e
  • / RES / values-e-V11

... where in each I have the following:

  • strings.xml
  • themes.xml

... where strings.xml is the localized text, and theme.xml has:

For directories other than v11 (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> 

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> 

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

 android:theme ="@style/MyTheme" 

It works in all languages ​​and on all devices, existing and obsolete, with the right choice of theme and everything. Tested on multiple physical devices.

So the question is:

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

Having a good work with the language in Android using strings.xml, is there any other way around this multitasking multilingualism and multilingualism?

Thanks.

+1
source share
1 answer

I'm not sure why you need something like

 values-de-v11 

I would just use something like this:

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

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

 values values-v11 

And inside you can add your own themes.

The values ​​in the folder should have both strings.xml for the default language (usually English) and a backup theme file for devices without a hologram.

You can check all the features in the documentation:

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

+1
source

All Articles