我想通了……以防其他人遇到相同/相似的问题;我把 html 放到一个文件中,每种语言一个文件……然后这是我用来加载文件的代码:
- (void)viewDidLoad {
[super viewDidLoad];
// determine what the language for this locale is...
NSURL *indexURL;
NSString *sysLangCode = [[NSLocale preferredLanguages] objectAtIndex:0];
// do we support this language?
if([sysLangCode isEqualToString:@"en"] || [sysLangCode isEqualToString:@"de"] || [sysLangCode isEqualToString:@"it"] ||
[sysLangCode isEqualToString:@"es"] || [sysLangCode isEqualToString:@"fr"] || [sysLangCode isEqualToString:@"ja"] ||
[sysLangCode isEqualToString:@"zh-Hant"] ) {
indexURL = [[NSBundle mainBundle] URLForResource: [NSString stringWithFormat:@"instRST-%@", sysLangCode]
withExtension:@"html"]; // contatenate the language code to the filename
}
else
indexURL = [[NSBundle mainBundle] URLForResource: @"instRST-en" withExtension:@"html"]; // make 'en' the default
[webView loadRequest:[NSURLRequest requestWithURL:indexURL]]; // load it...
}