Your method is a hacky way to get what you need, and requires app restart to take effect.
It is best to use NSLocalizedStringFromTableInBundle
instead of NSLocalizedString
, and provide the bundle for that language.
NSString* path = [[NSBundle mainBundle] pathForResource:@"ar" ofType:@"lproj"];
NSBundle* ar_bundle = [NSBundle bundleWithPath:path];
NSLocalizedStringFromTableInBundle(@"str", nil, ar_bundle, @"comment");
If you put the bundle in a global scope, you can create a macro for ease:
#define ARLocalizedString(str, cmt) NSLocalizedStringFromTableInBundle(str, nil, ar_bundle, cmt)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…