简体   繁体   中英

My localized strings are not detected

I'm trying to localize my strings in Xcode 4, but the only thing I get are the keys, not the values.

I've localized the strings using NSLocalizedString(key, comment) . I've generated the file Localizable.strings using genstrings from the command line. I've dragged and dropped Localizable.strings from Finder to Xcode (into the Resources folder). I've localized Localizable.strings and added the appropriate countries. I've made sure the encoding is UTF-16. I've translated the different Localizable.strings for each country. I've rechecked that the encoding is still UTF-16. I've checked that each statement in Localizable.strings ends with a semi colon.

Still not working.

Any idea of what I've missed?

edit

Here a part of my Localizable.strings

/* Text displayed on the comment button if there are more than one comment. */
"CommentButtonTextPlural" = "comments";

/* Text displayed on the comment button if there is exacly one comment. */
"CommentButtonTextSingular" = "comment";

/* Text displayed on the post button. */
"CommentViewPostButtonLabel" = "Post";

/* Default text displayed in the area where the user types in a comment. */
"CommentViewWriteAComment" = "Write a comment...";

/* Error message explaining that a document isn't viewable on the user's device. */
"DocumentRendererStatusDetailedErrorText" = "This document is not viewable on this device.";

/* Message explaining that the document is downloading. */
"DocumentRendererStatusDownloadingText" = "Downloading...";

You may be putting the Localizable.strings file in the wrong location so it's using the default translations.

When you add a new language, Xcode creates a new folder in your App Directory which ends in .lproj (so for English it would be en.lproj) and that is where your Localizable.strings file for English should be.

If you want a French one, add the French Language and Xcode will generate a fr.lproj directory and that is where the French Localizable.strings file will be located.

From your description, putting it in the Resources Folder is incorrect.

Your Localization should look like the following:

在此处输入图片说明

and on your desktop:

在此处输入图片说明

I managed to get it working.

What I did was remove the Localizable.strings (from the harddrive, I haven't touched the files located in the xx.lproj folders) file which genstrings created for me and removed the app-file on my device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM