Localized project with several targets with localized app names

馋奶兔 提交于 2019-11-30 11:09:00
Clafou

I cracked this nut in an XCode project which, I believe, tackles the same issue as you have, so hopefully this will help you. The solution contains two targets built from the same codebase (with a different app name) and which are fully localized, including the app's names. (It builds my freemium app called Growth (French: Croissance, Spanish: Crecer) and the paid version called Growth+ (French: Croissance+, Spanish: Crecer+).

I also stumbled on the InfoPlist.string files (which contain only the app's name). I got around the issue through the use of subfolders in my solution, and changing the targets to include the localized set of InfoPlist.strings from the relevant subfolder. Specifically, I have this structure:


    Root
    +-- en.lproj
    ¦   +-- Localizable.strings
    ¦   +-- SomeXib.xib
    +-- es.lproj
    ¦   +-- Localizable.strings
    ¦   +-- SomeXib.xib
    +-- fr.lproj
    ¦   +-- Localizable.strings
    ¦   +-- SomeXib.xib
    +-- OnlyInAppA
    ¦   +-- en.lproj
    ¦   ¦   +-- InfoPlist.strings
    ¦   +-- es.lproj
    ¦   ¦   +-- InfoPlist.strings
    ¦   +-- fr.lproj
    ¦       +-- InfoPlist.strings
    +-- OnlyInAppB
    ¦   +-- en.lproj
    ¦   ¦   +-- InfoPlist.strings
    ¦   +-- es.lproj
    ¦   ¦   +-- InfoPlist.strings
    ¦   +-- fr.lproj
    ¦       +-- InfoPlist.strings
    +-- AppA.plist
    +-- AppB.plist

And the only difference among my targets (other than different preprocessor symbols and different .plist file) is that AppA's build settings includes the InfoPlist.strings files under OnlyInAppA, whereas AppB's build settings includes the InfoPlist.strings files under OnlyInAppB.

The naming convention I used (OnlyInAppA/OnlyInAppB folders, AppB/AppB plist files) is obvious enough to make this a satisfactory approach, in my personal opinion.

Edit:

Please see these two XCode 4 screenshots to see where exactly to find the settings which are changed in the targets.

  1. In the target build settings, a different plist file is specified (note: XCode automatically does this for you when you add a new target)

  2. In the target build phases, in section Copy Bundle Resources, pick the version of InfoPlist.strings from the relevant OnlyInAppX subfolder (notice the gray text next to InfoPlist.strings on this screenshot--this will show a different location for the other target). You can achieve this by using the +/- buttons and replace the file with the intended one.

If this problem still persist: I have found a solution on how to add multiple InfoPlist.string localized for each target in your project. Please follow these steps:

  1. I assume you already have multiple targets.
  2. Go to the project folder in Finder.
  3. Create a folder specific for each target:

  4. Create an InfoPlist.strings file in each folder:

  5. Add folders to targets specifying proper (and only!) target for each folder in your project:

  6. Remove target dependency for original InfoPlist.strings file for each new target.

  7. Localize new InfoPlist.strings files:

  8. Build targets and check by changing language settings:

Just keep all the InfoPlist.strings files, under separate paths. Each would only be a member of one target.

Or did I not understand the question?

I have a similar setup where my the same software supports multiple domains, each domain accesses the exact same paths for various modules (e.g. blog, forums). In order to retain individuality per domain especially when the database service becomes unavailable I retain critical information in files, basically meta information. For localization I would keep a variable retaining each site/project's default language. You could determine the files containing the information to have their own domain or store all the projects in the same file, either way you would want to use that for your ultimate fallback or if you simply lack further public options to any/everyone with lower permissions than you until you implement such options (users being able to override the language option).

i have been doing exactly this for my apps.

as i change the default language for the phone, it properly picks up the names in each of my infoPlist.strings files.

but i did this from scratch. i don't know if you will have to back up to get the behavior you want. perhaps save aside your various infoPlist.strings files from any localization folders, then perform the following steps, and then re-insert your contents from your current infoPList.strings files into your newly created files from the following steps.

i am using Xcode 4.3 . the steps:

1) set up the strings you want in for your default language in info-plist.strings. you should end up with a single file:

2) now, open up the File Inspector

3) in the inspector on the far right, you can now click the + sign at the bottom of the navigator:

4) once you've chosen your language(s) of interest, they'll show up in your project navigator on the left as follows:

you also can do this for Localizable.strings and other files (such as the index.html in the following example photo):

Try see a iTunesConnect_DeveloperGuide

and see a "Adding a New Localization"

Here you can write a Localized app name for each language

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