gaussblurinc
gaussblurinc

Reputation: 3682

How should I store localized Strings in an iOS project?

I’m developing an iOS application. One of my tasks is localization. For this reason, I’ve taken all strings and put them each in a NSLocalizedString(key,comment), and everything’s been OK.

But my new solution is to create a Singleton class, which stores every String that I use in the project. With this I have one small, but tricky problem: naming. Do I need to create some dictionaries for every class (view) that needs localized strings? Or should I use prefixes for this, or functions that return objects with good, understandable property names?

P.S: i don't want to invent new wheel. I want to create STORAGE of localized strings, that will be used in project. So, my target is to make singleton:

[[[StringStorage sharedInstance] getStringsForClass:self] objectForKey:@"title"];

or something like this:

[StringStorage sharedInstance].stringTitleForMainView

Upvotes: 0

Views: 267

Answers (1)

anon
anon

Reputation:

You really should stick with NSLocalizedString and NSLocalizedStringFromTable. You also can use the NSBundle method localizedStringForKey:value:table:.

But if you take any other route you are reinventing the wheel, and you lose the ability to use the genstrings command line tool to extract all your strings from the source code.

Upvotes: 1

Related Questions