I have a localized iOS application in which I wish to include some localized HTML files. I can't work out how to do it.
Currently, my folder structure looks like this:
/myapp
/en.lrproj
/Localizable.strings
/fr.lrproj
/Localizable.strings
/webviews
/view1
/index.html
/pic1.png
/view2
/index.html
/pic2.png
As you can see, I currently have the views organized into their own folders with the associated images.
In XCode, when I selected the Localizable.strings files I can add new localizations. When searching for the solution to this problem I see that other people have done the same for the HTML files, however when I select the HTML files there are no options displayed for localizations, so I'm wondering if the folder structure is the problem.
On the other hand, I don't know how to structure the HTML into language code folders whilst not replicating the graphics that have to be along side.
Clearly I'm not understanding something - what do I need to do to get this working?
Thanks,
Tim
Arrange your index.html right next to the Localized.strings, keep the pics in the web views directory:
The build a file path:
The picture in the html tree are now similar to
Inside your index.html make the
<img>
tags point to../../../webview/pic1.png
(Not sure about the number of../
's that you need. You might want to open a terminal, navigate to /myapp/en.lrproj/view1/ and test withls ../../../webview/pic1.png
. )I assume "webviews/view1/index.html" is English, and "webviews/view2/index.html" is French.
in Localizable.strings of French
I tested above code using below in a ViewController.
"webviews" directory should be a "folder reference" in Xcode, not a group. (Blue directory icon, not yellow one)
Also, be careful not to add a slash after the directory name, like "webviews/view2/". I found that this could be a problem when I run that on iOS 5.x(I tested it on 5.0.1 and 5.1.1). But no problem on iOS 6.1.2.