Android Localization Question

I am working on translating an application. Looking at this , I see that in many countries there are several language codes.

I tried creating a folder called values-nb, for the Norwegian Bokmål. I changed the locale on my phones to Norway. This worked on my Sony Ericson Xperia 8, but not on the Samsung Galaxy Tab.

Then I tried to rename the folder to no values. Now it works on the galaxy tab, but not on xperia. I create both folders and it works. But then I have to put the same file in every folder!

What if someone chose Norwegian Nynorsk, I would need to create another folder so that they do not default to non-English, but get the Norwegian text? Values-nn?

I think my question is: How do I get this to work? Can I make all these folders and then make them refer to the values ​​- no? Please, help:)

+8
android localization
source share
3 answers

In accordance with the current search rules, there is no localization for a specific country and the ability to search in all languages. At least my understanding of reading pages at http://developer.android.com/guide/topics/resources/localization.html you would need to create values ​​-nn-rNO, values-nb-rNO and values-no- rNO and have duplicate .xml lines.

I have not tried this, but am looking at string aliases at http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources

+9
source share

I know this is old, but there is a trick to combine no, nb and nn as not:

Locale locale = getResources().getConfiguration().locale; if (locale.getLanguage().equals("no") || locale.getLanguage().equals("nb") || locale.getLanguage().equals("nn")){ locale = new Locale("no","NO"); Configuration config = new Configuration(); config.locale = locale; Resources res = getBaseContext().getResources(); res.updateConfiguration(config, res.getDisplayMetrics()); } 
+9
source share

Not the answer to the original question, but the solution for the corresponding problem, and this is the likely destination if you are looking for a solution to this problem (this was for me).

In our project, we created resource directories, but for some reason the localized strings were ignored.

The problem was Androids support for generating pseudo-localization resources. In older versions of Android, you did this using this magic in the build.gradle file:

 android.applicationVariants.all { variant -> // see http://blog.danlew.net/2014/04/16/android-localization-tips/ if (variant.buildType.isDebuggable()) { variant.mergedFlavor.addResourceConfiguration("zz_ZZ") } } 

This has changed in later versions of Android, and if you use it, then you will not get any localization. New way:

 buildTypes { debug { pseudoLocalesEnabled true } } 
0
source share

All Articles