views:

288

answers:

1

How can I let the user choose a specific localization in my app? I have a book and I'd like the users to be able to read all the different translations of it.

+1  A: 

You'll need to implement your own localisation methods.

One way to do this is to subclass NSBundle and override -pathForResource:ofType:inDirectory:forLocalization: and -pathsForResourcesOfType:inDirectory:forLocalization:. In your overrides, read from NSUserDefaults or whatever to decide which localisation to use then manually find the right one.

iKenndac
What about strings? NSLocalizedString()
Dimitris
NSLocalizedString is simply a macro that expands to -[NSBundle localizedStringForKey:value:table:] (Command+Double-click NSLocalizedString in Xcode to see the definition). I imagine this routes through -pathForResource:(etc) to find the strings file. If not, you'd have to override -[NSBundle localizedStringForKey:...] as well.
iKenndac
Thanks for all that. But it sounds like too much hassle.. I'll try to find another way to do this and I'll let you know.
Dimitris
I am sorry for not accepting your answer as correct, but I haven't had the time to try it our yet.
Dimitris