Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have both res/values-pt_PT and res/values-pt_BR on Android?

I keep getting an error when creating folders for internationalization. But the errors appear just for folders with the name like values-xx_XX. If I have values-xx everything is ok, but like I asked in the title I want to make 2 separate folders for the (aprox.)the same language: values-pt_PT,values-pt_BR. How can I do that without getting any errors? Note: The error is not specified anywhere, the eclipse is just marking the folder with a red cross and doesn't allow me to run the project.

Every hint is appreciated. Thank you! :)

like image 625
Ispas Claudiu Avatar asked Jul 09 '14 13:07

Ispas Claudiu


2 Answers

Use the format values-xx-rXX instead of values-xx_XX. In this instance you should use values-pt-rPT and values-pt-rBR.

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

The language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r").

like image 140
Nachi Avatar answered Sep 23 '22 10:09

Nachi


I haven't done it myself, but after a quick search here, I found Setting region based Local in android where they suggest using the constructor as you did:

Locale locale = new Locale("ar","SA"); //(language,country)

But also, if you wish to pass it as one parameter, you'd still leverage the lowercase "r" as in the "values" folder, like this:

 Locale locale = new Locale("ar-rSA");

Hope it helps :)

like image 21
Daniel Neumann Avatar answered Sep 21 '22 10:09

Daniel Neumann