localizable.strings - translate strings from code

231 Views Asked by At

is there a possibility to set cocoa app, so it will translate NSString (placed in code) after launching without need of using NSLocalizedString ?

Thanks for help !

2

There are 2 best solutions below

0
On BEST ANSWER

The answer is no. And you probably wouldn't want this anyway, as not every string should be localizable. Some of your strings may contain display text and hence need to be localizable through NSLocalizedString, and on the other hand some other of your strings may affect your logic, such as strings that define the name of a resource (e.g. the string you pass to loadNibNamed or the name of an image or audio file to load). These are really meant to be hardcoded and translating them would break your application.

1
On

Not automatically, but you could create a simple macro to cut down on typing:

#define TRANS(s)    NSLocalizedString(s, nil)