views:

70

answers:

2

Hi everybody.

I've got an iPhone app that need to be localized. No problem with strings, but, I'm having trouble with resources : I need to load HTML pages that are localized. The files are like : presentation.htm The files are added in the project with the folder where they are (html/), and it add the group called as the folder.

I load the html pages with this code :

NSString *pathPresentation = [[NSBundle mainBundle] pathForResource:@"presentation" ofType:@"htm"];

if(!pathPresentation) {
    NSLog(@"Could not find presentation.htm");
}
NSURL *url = [NSURL fileURLWithPath:pathPresentation];
NSLog(@"-> path presentation.htm : %@", pathPresentation);
UIWebView *webViewPresentation = [[UIWebView alloc] init];
NSData *htmlData = [NSData dataWithContentsOfFile:pathPresentation];  
if (htmlData) {  
    [webViewPresentation loadData:htmlData MIMEType:@"text/html" textEncodingName:@"Latin-1" baseURL:url];  
}

First Try :

I've followed the indications of this website I Can Localize, since there was yet localized resources in the app. The folders are named : en.lproj and fr.lproj.

I try it on the simulator, but it didn't succeed :

  • the log indicates that the path is : (...)/myapp.app/presentation.htm
  • the file loaded in the simulator is in french, while the simulator is in english.

Second Try :

Then, I delete the resources and re-add them in their group folder (Resource/html/). I pressed the Info button, and choose to "Make file localizable". The file was added in a English.lproj folder. Then I choose "Add Localization", and "French".

I try it on the simulator, but it didn't succeed (I have clean the build before testing) :

  • the log indicates that the path is : (...)/myapp.app/presentation.htm
  • the file loaded in the simulator is in french, while the simulator is in english.

Third Try :

After reading this page about loading localized resources on iPhone OS 4.0, I've changed the resources in localized folders (delete resources, and rename folders in *en_UK.lproj* and *fr_FR.lproj*

I try it on the simulator, but it didn't succeed (I have clean the build before testing) :

  • the log indicates that the path is : (...)/myapp.app/presentation.htm
  • the file loaded in the simulator is in french, while the simulator is in english.

Help ?

Any idea ? I know there is the function : - (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)subpath forLocalization:(NSString *)localizationName

But I want it to be as automatic as possible, and fixing things like Directory or localizationName may prevent my app to be automatic.

+1  A: 

The solution is :

  1. remove application from simulator
  2. use simple localized folders, as : en.lproj
  3. clean build
AlexandreD
A: 

thanks very much, it works.

disorderdev