Portuguese Brazil and Portuguese Portugal Localization Problem

Hello,

I am using Xcode 8.3.2 and we made our app to support for Portuguese Portugal (PT-PT) localization and it's working fine for Portugal. When I launch app with Portuguese Brazil (PT-BR) language as a system language, then the app is localized with Portuguese Portugal instead of English language. We haven't imported or added Portuguese Brazil Xliff and there is no PT-BR file anywhere in the project. Can anyone provide solution for the same?


Regards,

Rohith Nayak

Replies

Problem exists in 10.11 and later OS

If I remember correctly, you should define a localization folder name PT (not PT-PT) to work with all regional variations.


Or duplicate PT-PT as PT-BR.


if not found, it falls back to :

- language only folder

- default folder if not found (english in your case)


Here are the rules

If the application cannot find a folder that is an exact match, it will then look for a localization folder in the application bundle that matches just the language code without the region code. So, staying with our French-speaking person from France, the application next looks for a localization folder called fr.lproj. If it doesn’t find a language folder with that name, it will look for fre.lproj and then fra. lproj. If none of those is found, it checks for French.lproj. The last construct exists to support legacy Mac OS X applications; generally speaking, you should avoid it.

If the application doesn’t find a language folder that matches either the language/region combination or just the language, it will use the resources from the development base language. If it does find

an appropriate localization folder, it will always look there first for any resources that it needs. If you load a UIImage using imageNamed(), for example, the application will look first for an image with the specified name in the localization folder. If it finds one, it will use that image. If it doesn’t, it will fall back to the base language resource.

If an application has more than one localization folder that matches—for example, a folder called fr-CH.lproj and one called fr.lproj—it will look first in the more specific match, which is fr-CH.lproj if the user has selected Swiss French as their preferred language. If it doesn’t find the resource there, it will look in fr.lproj. This gives you the ability to provide resources common to all speakers of a language in one language folder, localizing only those resources that are impacted by differences in dialect or geographic region.

Hello Claude,

Thanks for the reply. My problem is that I don't want Portuguese Brazil localization in my project. I want only Portuguese Portugal language. I imported only portufuese file, but when I run my app with Portuguese Brazil language, I am getting localized text of Portugal, which is wrong. So I want to know how to avoid this. I tested in various OS version and I found that this problem started from OSX 10.11 and above.


Regards,

Rohith Nayak

You say :

when I run my app with Portuguese Brazil language, I am getting localized text of Portugal, which is wrong

So, what do you want to get in that case, if it is neither pt-PT nor en ?

If you want pt-BR, you need to create a localization for it. // I think language is lowercase


Logic, when user selects pt-BR :

- if localization found, use it

- if not, look if there is a pt localization ; if so, use it

- otherwise use default : eg english.

I am expecting en language as there is no pt-BR file. But actual output is coming as pt-PT.

Hello Rohith,

What you are asking for is nor directly possible As far as I know The system will prefer a matching language, even if the dialect is wrong, over a different language. You would have to define a pt-br language and use English.

Have a look here

h ttp://www.oneskyapp.com/blog/ios-10-localization-wwdc/


It is a sumary of WWDC16/201 conference.


Hope it helps, with how to set language hierarchy.

Hello John,

I am afraid that the above fix will add PT-BR language support in our app language section in appstore.


Regards,

Rohith