1

I've successfully added a French localisation to my app. In XCode 4, it was just a case of selecting Localizable.strings and adding a new (French) localisation in the File Inspector. I then copy/pasted the French translation (from Word - unicode 16) into the new Localizable.strings (French) file that was generated.

I changed the language of the phone (both device and simulator) to French and removed the currently installed app, cleaned, and built.

Hey presto - everything's in French. Except that there are a few lines here and there that have remained in English. There seems to be no common element to these lines - either accents, formats or arguments.For example:

title = [NSString stringWithFormat:NSLocalizedString(@"You've just met %@", @"New friend message title"), self.friend.name];

/* New friend message title */  
"You've just met %@" = "Vous venez de rencontrer %@";

Still appears as 'You've just met ...' rather than in French. I can't seem to figure out why these few lines aren't translating when everything else is. Any help much appreciated!

Thanks, Michael.

Smikey
  • 8,106
  • 3
  • 46
  • 74
  • Could you share a little more source code ? I would like to see both english and french localizable.strings line for the example above. Also you don't need to delete your app and reinstall for localization. But you must stop the app running with Xcode before you change the language. – Daniel Jan 13 '12 at 11:26
  • I face the same problem. I just cut the text and paste into top in Localizable.string. I know it's non technical but it's work for me – Hiren Jan 13 '12 at 11:26
  • have you set the french text for "You've just met" in Localizable.strings file? – Mudit Bajpai Jan 13 '12 at 11:29
  • The answer seems to have done it - copy/pasting from word was the culprit. – Smikey Jan 13 '12 at 12:55

2 Answers2

1

You can't use high ascii characters in NSLocalizedString function.
To fix it simply change your key string:

title = [NSString stringWithFormat:NSLocalizedString(@"YouveJustMetStr", @"New friend message title"), self.friend.name];

"YouveJustMetStr" = "Vous venez de rencontrer %@";
Tomasz Wojtkowiak
  • 4,910
  • 1
  • 28
  • 35
  • That seems like a plausible explanation except that ' isn't a high ascii character, unless you've actually used a 'smart' apostrophe character by copying and pasting the string from MS Word, and it's just appearing as a regular ' in StackOverflow. – Nick Lockwood Jan 13 '12 at 12:16
  • I given in my current project Localized String is not working but, in other projects it is working.There is no error. Please help me – Vineesh TP Apr 10 '12 at 08:34
1

Microsoft Word is not a plain text editor, and it will modify text by replacing certain punctuation (apostrophes, quotes, dashes) with "smart" versions that look a bit nicer but might have random unicode code points.

I suggest checking that the apostrophe in "You've just met" is exactly the same character in your strings file as it is in your code source file. Maybe copy the "You've just met" from the strings file directly into the NSLocalizedString statement in your code and see if that helps.

I'd also recommend not using Microsoft Word to generate machine-readable strings unless you want a lot of headaches!

Nick Lockwood
  • 40,865
  • 11
  • 112
  • 103
  • That seems to have done the trick! I just re-typed the ' in the strings file and now the line appears in French. The strange thing is that I have about 1000 lines, many of them with apostrophes. I suppose it's possible the person working on the translation in Word may have replaced it by accident. Word seems a necessary evil since my translators couldn't open .strings files and I needed something familiar. But opening a .strings file in Word should keep the UTF16 formatting shouldn't it? Is there a better way to give docs to translators in a familiar format perhaps? Or at least converting it. – Smikey Jan 13 '12 at 12:52
  • No, Word doesn't support unicode properly, so it won't preserve UTF16. You could ask the translators to ensure that the "auto insert smart quotes" feature is disabled in their MS Word preferences, but your safest bet is probably to just manually check all your files after you get them back, as you have been doing. – Nick Lockwood Jan 13 '12 at 17:35