We might have a need for loading a nib using the results of
[NSBundle -pathForResource:ofType:inDirectory:forLocalization:]
I thought this would be possible, but all the methods I can find only want the name not leading path info.
We are exploring a way to provide both fr-Fr and fr-CA through one code base. Our client wants a fr-CA translation and we’re afraid we might have another customer that wants a fr-Fr translation. I was thinking we could path to correct nib based on the selected language.
Thanks
The path lookup takes into account the user’s locale preferences. If you provide the proper localization directories (
.lproj), the right nib should be loaded by the system.Per Apple’s documentation:
Unfortunately, Apple’s documentation is self-contradictory and incomplete. If you look at “Internationalization and Programming Topics”, section “Language and Locale Designations”, you will find under “Language and Locale IDs” this gem:
This is not entirely true. If you look at Apple’s own applications, you will see that iOS does support some region designations, but only the ones Apple cares about. See for example the list of .lproj directories in a recent Mobile Safari:
Notice that two Chinese regions, a British English region, and a Portugal Portuguese region are supported. But none of these solves the problem of
fr_CAversusfr_FR.For that, let’s look at MobileSafari again. It must implement its own smart lookup, because it has plenty of more finely distinguished
StaticBookmarks-xx_YY.plistfiles.So, that’s the solution: Use the locale functions that are still available, and do your own lookup accordingly.