13

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! :)

2 Answers 2

28

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").

2
  • This seems to be the answer. Indeed the documentation specifies this problem, next time I should search/look with more attention. But now I have another problem. What string should I give as a parameter to Locale? if for example I have the folder values-pt-rBR what should be the string? I already tried pt_BR but it doesn't work. Thx for the answer Jul 9, 2014 at 13:58
  • 2
    Ok I found the solution. I used another constructor Locale("br","BR") and it works. I still don't know why it doesn't work Locale("br_BR"). Thank you for the answer! Jul 9, 2014 at 14:12
2

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 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.