I want to localize strings in my iphone app for en_GB and other \'en\' sub-languages, but XCode and the iphone refuse to let this happen. I have created a localization of \"Loca
Create a separate string resource, say UKLocalization.strings
, and create localizations for each of your supported languages. For all localizations other than en
this file is empty. For en
, it contains only the strings that have unique en_GB spelling.
Next, you create a replacement for NSLocalizationString that will first check the UKLocalization table before falling back to the standard localization table.
e.g.:
static NSString* _locTable = nil;
void RTLocalizationInit()
{
_locTable = nil;
NSString* country = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
if ([country isEqual:@"GB"])
{
_locTable = @"UKLocalization";
}
}
NSString* RTLocalizedString(NSString* key, NSString* ignored)
{
NSString* value = nil;
value = [[NSBundle mainBundle] localizedStringForKey:key value:nil table: _locTable];
if (value == key)
{
value = NSLocalizedString(key, @"");
}
return value;
}