iOS how to manual language to your app

There are approach to localize an iPhone app already. In this article we are going to learn how to get localize string file , and then transfer to NSDictionary class. By NSDictionary object, we can get localize string by inputing dedicated key.


NSString *path = [[NSBundle mainBundle] pathForResource:@"Localizable" ofType:@"strings" inDirectory:nil forLocalization:@"zh-Hant"];
    
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSString *twTranslation = [dict objectForKey:@"TITLE"];
    
NSLog(@"%@", twTranslation);

0 意見: