To avoid all those lengthy syntax and more having more descriptive var name for translators, I derived my own helper method L()
for translation and falling back to English
NSString * L(NSString * translation_key) {
NSString * s = NSLocalizedString(translation_key, nil);
if (![[[NSLocale preferredLanguages] objectAtIndex:0] isEqualToString:@"en"] && [s isEqualToString:translation_key]) {
NSString * path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];
NSBundle * languageBundle = [NSBundle bundleWithPath:path];
s = [languageBundle localizedStringForKey:translation_key value:@"" table:nil];
}
return s;
}
My Localizable.strings
would look like this
"SOME_ACTION_BUTTON" = "Do action";
So in my code, i would use L(@"SOME_ACTION_BUTTON")
to get the correct string
Though sometime the key is longer than the translation itself HELP_BUTTON_IN_NAV_BAR = 'Help'
but it saves me a lot of time explaining what it is to whoever is helping me doing the translation
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…