Localization of the iPhone Settings.bundle

2019-04-03 07:28发布

For some reason I cannot get the Settings.bundle to recognize my additional languages. I must be missing something obvious, but I just cannot figure it out. Here's what I've got:

Project Structure in XCode:

XCode Screen Shot

Root.plist file:

Root.plist file http://img227.imageshack.us/img227/571/screenshot20100624at334.png

French Root.strings file

french Root.strings file http://img121.imageshack.us/img121/571/screenshot20100624at334.png

From everything I've read, I believe the project structure is right. The StringsTable in the Root.plist matches the name of the individual .strings files, and the Key for each item in the Root.plist has a match in the .strings files as well.

Why don't I see French text in my settings when I change the default iPhone language?

Thanks in advance!

6条回答
Juvenile、少年°
2楼-- · 2019-04-03 08:06

I'll go ahead and answer my own question since I solved the problem myself through testing and failing. Hopefully this will help someone else in the future.

First, I think my Root.plist file may have been corrupted. I'm not exactly sure why, but I completely deleted the Settings.bundle, and re-created it to be sure.

Second, and perhaps most importantly, the main issue was the "key" in the root.strings file didn't match to the "key" field in the Root.plist, it actually matches the "Title" field.

Once I made those changes to the Root.strings file, it all started to work.

查看更多
贪生不怕死
3楼-- · 2019-04-03 08:12

For me, the problem was leaving off a semi-colon!

In localizable.strings, you get a runtime error if you omit the ";", but in Root.strings, you don't get any warnings, you can run it fine, but it just won't work!

So double-check to make sure you punctuate each key:value pair with a semi-colon!

查看更多
唯我独甜
4楼-- · 2019-04-03 08:12

All you have to do is keep (or Add, if it's not there) "Strings Filename" in the Root.plist, after your settings.

Check the image with example

Then, add Value "Root" (or, the name of your file and the translations) to make the created lang.lproj translations functional.

查看更多
老娘就宠你
5楼-- · 2019-04-03 08:27

After some repeated tries to activate localization,following steps worked for me:

  1. Close xcode
  2. Drag and duplicate the settings bundle onto the desktop (or wherever)
  3. Open bundle contents
  4. Drag Root.strings into the en.lproj folder
  5. Duplicate the en.lproj folder and rename to whatever language you want (using 2-letter code ie fr.lproj)

  6. Replace the original settings bundle with the new one(without opening xcode).

  7. Now Open xcode and the new files and folders should be there

Now delete the older app and run xcode,Works fine in simulator and on device.

NOTE:Closing xcode,updating of duplicated setting bundle outside xcode and replacing updated back only will help.

查看更多
放荡不羁爱自由
6楼-- · 2019-04-03 08:30

In Xcode 5 there is still no obvious way to localize the Settings.bundle.

The problem

Xcode doesn't allow you to localize a file that is only shown because it is a file inside a folder that's directly shown in Xcode (hence the blue folder icons in the tree).

The Solution:

  1. right-click the Root.strings file and select "Show in Finder"
  2. List item
  3. move the Root.strings file one folder up, so that the en.lproj folder is empty and the Cmd-Drag the Root.strings file is next to the Root.plist.
  4. delete the now empty en.lproj
  5. go back to Xcode, notice that the tree will reflect the changes you now made
  6. cmd-drag the file in the tree outside to outside the settings-bundle, so that it appears next to your source-code.
    • Do not copy the file
  7. a dialog will appear asking you what to do with the file.
    • DO NOT select the checkbox to copy the file (you need this to be a reference)
    • DO NOT select a target to include the strings-file (the settings.bundle is already assigned to the correct target)
  8. in the file inspector you can now choose to localize the file and to add languages to the localizations. The files will be placed correctly inside the settings.bundle and the tree will automatically reflect these changes, too.
查看更多
乱世女痞
7楼-- · 2019-04-03 08:30

In my case, it appeared as if "Strings Filename" was set to "Root" in the Property List View of Root.plist, but when viewed the file in Source Code View, it was actually "StringsTable" pointing to "Root". The solution is to add another entry where "Strings Filename" points to "Root". (I also tried deleting the previous entry, but then it stops working, so you need both.)

查看更多
登录 后发表回答