spritebuilder / SpriteBuilder

Objective-C Game Development Suite
http://www.spritebuilder.com/
Other
739 stars 292 forks source link

Localization broken in iOS 9 #1602

Open streamside7 opened 8 years ago

streamside7 commented 8 years ago

Both the built-in localization system and CCBLocalize do not seem to be working in iOS 9. I have compiled several projects in both Xcode 6.4 and the latest beta of Xcode 7.

When I debug from Xcode and specifically change the scheme to run under an alternate language, the code will run fine, and the language is set properly.

When I designate it to run under the system language (which has been changed in the Settings), it defaults the base language.

I will look into this myself, and contribute back to the community, but my understanding of the internals of Cocos2D are limited.

Thanks,

Roger Pingleton

FlashDoc commented 8 years ago

I have found the same issue. I have debugged the CCBLocalizationManager and found out that the preferred languages provides by NSLocale have the format "de-DE" or "en-DE" for example. The first part of this language code in the language and the second part the region.

There are two ways to fix this issue: Change the language keys in the strings.ccb file or split the language codes from NSLocale into language and region and use only the language part.

Edit: The best fix is using [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode] to get the current user language code. Check this language code again the activeLanguages. If this array contains ths current user language code, the translations can be created.