How do I change the Development language in Xcode before internationalizing my app?

泪湿孤枕 提交于 2019-12-18 11:03:19

问题


I'm taking over an app that was written entirely in French. Strings are hardcoded in French in the code, and all the messages in the storyboard are in French. But the initial development region in Info.plist was left to English. So I changed CFBundleDevelopmentRegion to fr so that it matches the real language that was used. But XCode keeps telling me that my Development language is English:

How can I correct that? The goal is to be able to activate Base Internationalization and have it use French as the Base language instead of English.


回答1:


The following procedure worked for me, but it includes manually editing project.pbxproj file:

  1. Quit XCode
  2. Open the project.pbxproj file with your favorite text editor
  3. Update the following section (near developmentRegion):

OLD:

    developmentRegion = English;
    hasScannedForEncodings = 0;
    knownRegions = (
        en,
        Base,
    );

NEW:

developmentRegion = fr;
            hasScannedForEncodings = 0;
            knownRegions = (
                fr,
                Base,
            );

I've created a GitHub repository with a sample project that was initially created with English as default Development Language, and then updated by the procedure above to use French as Development Language.




回答2:


I might have figured it out.

I have built an app in Swedish, but the development language is set to English.

I edited MyProject.xcodeproj/project.pbxproj manually. There are two lines like this:

91C8245918BDFA6100A9972F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };

and this section:

developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
        en,
        Base,
);

Changing all "en" to "sv" like this:

91C8245918BDFA6100A9972F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/InfoPlist.strings; sourceTree = "<group>"; };

and

developmentRegion = Swedish;
hasScannedForEncodings = 0;
knownRegions = (
        sv,
        Base,
);

and moving the file MyProject/en.lproj/InfoPlist.strings to MyProject/sv.lproj/InfoPlist.strings seems to have fixed it. Now the "Development Language" shows up as Swedish, and I can add an English translation.

After adding the translation, the storyboard has an expand-triangle where the base language is the existing Swedish version, and the translation is a strings-file in english.




回答3:


I wanted to develop the project in my own "developer" language by using placeholders instead of real texts in example "WLAN_NOT_AVAILABLE" inside of NSLocalizedString which later on will be translated in different languages including english, off course. I do not like when I must write whole sentences right in the code.

I did just open *.pbxproj file inside of *.xcodeproj folder and changed the following line to:

developmentRegion = Base;

After that English was no more set as development language and I was able to treat it as any one else. This gives you as developer the possibility to write short text placeholders and delegate the correct spelling to another in your team.




回答4:


I hope I understood the question. AFAIK, it's quite simple to achieve what you want using the Xcode's GUI as described here: https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/InternationalizingYourUserInterface/InternationalizingYourUserInterface.html




回答5:


Select the Info.plist file under Supporting Files group in the Project Navigator (on the right). Then, in the editor-view in the Localization native development region click on the up-and-down-arrows on the right of 'English' and select France.

This should be it. Although, Xcode sometimes doesn't update the "Info" view of the project settings.




回答6:


Here is a Ruby script to change the development region in the Xcode project using the cocoapods libraries:

require 'fileutils'
require 'Xcodeproj'

filename = ARGV.first

raise "Argument '#{filename}' is not a valid .xcodeproject" unless filename && File.directory?(filename) && File.extname(filename).downcase == ".xcodeproj"

puts "Region to set: "
region = $stdin.gets.chomp

project = Xcodeproj::Project.open(filename)
project.root_object.development_region = region
project.save

puts "#{project.path}", "development_region = #{project.root_object.development_region}"

https://www.ralfebert.de/snippets/ios/xcode-change-development-language/



来源:https://stackoverflow.com/questions/30695493/how-do-i-change-the-development-language-in-xcode-before-internationalizing-my-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!