MADPT
MADPT

Reputation: 97

Localize an NSArray

I've been localizating my app with this method:

.m file

... initWithTitle:NSLocalizedString(@"CONFIRMACAO_TEL", @"Message")

Localizable.strings file

"CONFIRMACAO_TEL" = "Do you want to call?";

The last data that I've to localize are two NSArray's and, despite all the searching, I still can't figure it out how to do it.

Here's my array:

descricaoServicos = [[NSArray alloc] initWithObjects:@"test 1, test 2", @"test 3", @"test 4", nil];

Upvotes: 2

Views: 1686

Answers (2)

jlngdt
jlngdt

Reputation: 1368

As Nikos said indirectly, you can't do it better.

But you can short it using a macro like this :

#define Local(str) NSLocalizedString(str, nil)

Your code will be a bit shorter

Upvotes: 0

Nikos M.
Nikos M.

Reputation: 13783

You can localize like this:

descricaoServicos = [[NSArray alloc] initWithObjects:NSLocalizedString(@"test 1, test 2",@"test 1, test 2"), NSLocalizedString(@"test 3", @""), NSLocalizedString(@"test 4", @""), nil];

Upvotes: 2

Related Questions