0

I want to load an html file no my app depending on the device language. I already have the code to load an html file without checking the language but now i want to load a file with the format: filename_[LANGUAGE].html

here is my loadHtml code:

self.htmlFile = [_htmlFile stringByReplacingOccurrencesOfString:@".html" withString:@""];
NSString * htmlFilePath = [[NSBundle mainBundle] pathForResource:_htmlFile ofType:@"html"];
NSString * html         = [NSString stringWithContentsOfFile:htmlFilePath encoding:NSUTF8StringEncoding error:nil];

what is the best way to do this?

4

1 回答 1

2
 NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];

This will return a two letter code for the currently selected language. "en" for English, "es" for Spanish, "de" for German, etc.

于 2013-08-16T10:07:23.367 回答