Localizing concatenated or dynamic strings
Posted
by SooDesuNe
on Stack Overflow
See other posts from Stack Overflow
or by SooDesuNe
Published on 2010-03-17T01:40:44Z
Indexed on
2010/03/17
1:51 UTC
Read the original article
Hit count: 398
I'm familiar with using NSLocalizedString() to localize strings, but the problem I have today requires a little more finesse. My situation is like this:
NSString *userName; //the users name, entered by the user. Does not need localized
NSString *favoriteFood; //the users favorite food, also entered by user, and not needing localized
NSString *summary = [NSString stringWithFormat:@"%@'s favorite food is %@", userName, favoriteFood];
This works fine for english, but not every language uses the same word ordering as English, for example, a word-by-word translation of the same sentance from Japanese into English would read:
UserName's favorite food pizza is
Not to mention that 's is doesn't make a possessive in every language.
What techniques are available for localizing this type of concatenated sentence?
© Stack Overflow or respective owner