2
votes

I have a couple of targets for my app. I am trying to localize them differently. I have found this to be pretty easy when dealing with a Localizable.strings file and the NSLocalizedString macro. To get this to work I simply adjust the target membership of the Localizable.strings file for the target I am working with. So my project file structure looks something like:

  • project
    • target1
      • en.lproj
        • Localizable.strings
      • it.lproj
        • Localizable.strings
    • target2
      • en.lproj
        • Localizable.strings
      • it.lproj
        • Localizable.strings

Now my project has 2 targets being built with completely different english translations. Perfect, this is what I want.

My difficulty comes into play when I try to do the same thing for the *.strings files that are generated when localizing a view. My deployment target is 6.0 and I am using storyboards with base internationalization. So when I add a view to my project structure it will look like:

  • project
    • target1
      • Base.lproj
        • SomeStoryboard.storyboard
      • en.lproj
        • Localizable.strings
        • SomeStoryboard.strings
      • it.lproj
        • Localizable.strings
        • SomeStoryboard.strings
    • target2
      • en.lproj
        • Localizable.strings
        • SomeStoryboard.strings
      • it.lproj
        • Localizable.strings
        • SomeStoryboard.strings

My goal was to let each target have a different localization for each target, yet maintain the same Base storyboard. I also wanted to avoid something like: naming the target2 storyboard string files something like REPLACEMENT_SomeStoryboard.string and then writing a script that for every file named such in a given target delete SomeStoryboard.string and rename REPLACEMENT_SomeStoryboard.string to SomeStoryboard.string.

Attempt #1

So what I tried to do was remove the target1 en.lproj/SomeStoryboard.strings & it.lproj/SomeStoryboard.strings from the target2 membership. But this also removed the Base.lproj/SomeStoryboard.storyboard from the target2 membership. So basically membership was managed as if it were one file, which makes sense.

Attempt #2

The second thing I tried was to add target1 SomeStoryboard.storyboard to the membership of target2 and also create a SomeStoryboard.strings file and add that to the membership of target2. I tried adding this extra strings file into the Copy Bundle Resources Phase. I also tried adding the Copy Files Phase (after the Copy Bundle Resources Phase). Either way it appeared to only occasionally replace the SomeStoryboard.strings from target1. So the end result was that sometimes target2 picked up the localization from target1 and sometimes it was localized from target2.

1
Did you ever find a suitable answer for this? I'm in the same spot. - edelaney05

1 Answers

1
votes

Try using the method described at http://smoothlocalize.com/ (click on the first tutorial in the first main box). You download a small library that allows you to use Localizable.string for your resource strings the same way you do for .m files.