NSLocalizedString: confusion with short string - substring

111 Views Asked by At

In my code I use a lot of localized strings and all works great, except with short strings.

Example

NSString* text = [NSString stringWithFormat:NSLocalizedString(@"%@ at %@", nil), dateStart, timeStart];

In file localizable.string I have:

"%@ at %@" = "<translation>"
"attending %@" = "<translation>"

In my opinion, compiler fails when try to get the right string.. how can I achieve this?

1

There are 1 best solutions below

2
On

The left side is the key for the copy on the right side.
It's not the key that should have the placeholders in it, as the string is exchanged at runtime by the string from the locale.strings.
In other words: after localization you are missing the %@

To achieve what you want, you need the placeholders to be in the translated string:

"SOME_KEY" = "%@ <localized> %@"