7 Replies
      Latest reply on Jan 8, 2019 1:57 AM by eskimo
      alberto_mota Level 1 Level 1 (0 points)

        I have multiple targets in my app: targetA and targetB.  Whenever i "Export For Localization", the .xliff generated will cointain translations for:

         

        1) Main.storyboard

        2) targetA/InfoPlist.strings

        3) targetB/InfoPlist.strings

        4) targetA/Localizable.strings

        5) targetB/Localizable.strings

         

        I want to avoid multiple Localizable.strings, and multiple InfoPlist.strings. We do not need one localization per target.

         

        Any way i can  force the "Export For Localization", to create a .xliff   that only contains one Localizable.strings and one InfoPlist.strings?

        • Re: Export For Localization with multiple targets
          eskimo Apple Staff Apple Staff (10,595 points)

          I’d like to clarify your setup here.  As a starting point, let’s consider your InfoPlist.strings file.  Based on your post I believe you have one InfoPlist.strings that’s a member of both targetA and targetB.  Is that right?

          Is that true for every localised resource?  Or just some subset?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Export For Localization with multiple targets
              alberto_mota Level 1 Level 1 (0 points)

              Thanks a lot for replying.

               

              Yes, I have two Info.plist, one per target.

              I have only one storyboard. The storyboard is memeber of both targetA and targetB.

               

              I want to avoid multiple Localizable.strings, there are being created two(one per target)

               

              Any way i can  force the "Export For Localization", to create a .xliff   that only contains one Localizable.strings?

                • Re: Export For Localization with multiple targets
                  eskimo Apple Staff Apple Staff (10,595 points)

                  What version of Xcode are you testing this with?  I used Xcode 10.1 to create a project that has two targets, and then added a Common directory containing a Localizable.strings.  The exported en.xcloc looks like this

                  en.xcloc
                  en.xcloc/Localized Contents
                  en.xcloc/Localized Contents/en.xliff
                  en.xcloc/Notes
                  en.xcloc/contents.json
                  en.xcloc/Source Contents
                  en.xcloc/Source Contents/TargetA
                  en.xcloc/Source Contents/TargetA/en.lproj
                  en.xcloc/Source Contents/TargetA/en.lproj/InfoPlist.strings
                  en.xcloc/Source Contents/TargetA/Base.lproj
                  en.xcloc/Source Contents/TargetA/Base.lproj/LaunchScreen.storyboard
                  en.xcloc/Source Contents/TargetA/Base.lproj/Main.storyboard
                  en.xcloc/Source Contents/TargetB
                  en.xcloc/Source Contents/TargetB/en.lproj
                  en.xcloc/Source Contents/TargetB/en.lproj/InfoPlist.strings
                  en.xcloc/Source Contents/TargetB/Base.lproj
                  en.xcloc/Source Contents/TargetB/Base.lproj/LaunchScreen.storyboard
                  en.xcloc/Source Contents/TargetB/Base.lproj/Main.storyboard
                  en.xcloc/Source Contents/Common
                  en.xcloc/Source Contents/Common/en.lproj
                  en.xcloc/Source Contents/Common/en.lproj/Localizable.strings

                  As you can see, there’s only one copy of Localizable.strings is the Source Contents directory.  More to the point, the string I put in Localizable.strings only shows up once in the en.xliff.

                  $ grep aaa en.xcloc/Localized\ Contents/en.xliff 
                  <trans-unit id="aaa">

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"

                    • Re: Export For Localization with multiple targets
                      alberto_mota Level 1 Level 1 (0 points)

                      I got the same directory structure.

                      The issue is when you open en.xliff. Inside the xliff, is gonna ask for two translations for Localizable.strings.

                      However, our grep commands return different results!!!

                       

                      $ grep hi fr.xliff
                      
                      <trans-unit id="hi">
                           <source>hi</source>
                      <trans-unit id="hi">
                           <source>hi</source>
                      

                       

                      What can we have different? I duplicated the first target, see my project: https://github.com/albertomota-codes/LocalizationTargets

                        • Re: Export For Localization with multiple targets
                          eskimo Apple Staff Apple Staff (10,595 points)

                          Thanks for posting the test project.  That allowed me to see what’s different between your case and mine.  In your case you have Export For Localization generated the Localizable.strings file on the fly from your various calls to NSLocalizedString.  In my case I added Localizable.strings as its own file in my target.  If I add such a file to your project and then include it in both targets, the resulting fr.xliff file only contains a single instance of strings therein.

                          Share and Enjoy

                          Quinn “The Eskimo!”
                          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                          let myEmail = "eskimo" + "1" + "@apple.com"

                            • Re: Export For Localization with multiple targets
                              alberto_mota Level 1 Level 1 (0 points)

                              Eskimo, thanks a lot! Now it makes sense. However, i am not able to reproduce: "If I add such a file to your project and then include it in both targets, the resulting fr.xliff file only contains a single instance of strings " How do you add such file? How do you include it in both targets? I have tried  by creating a new file using Xcode and adding it to the both targets at the creation without success. I have tried  by creating a new file using  third-party text processor, then add it to the project and to both targets at the same time without success. Thanks for your help!

                                • Re: Export For Localization with multiple targets
                                  eskimo Apple Staff Apple Staff (10,595 points)

                                  I can’t recall exactly what I did (it’s been a few weeks) but I don’t think I did anything special.  It was probably New > File > Strings File followed by tweaking the target inclusion and localisations using the File Inspector.

                                  Share and Enjoy

                                  Quinn “The Eskimo!”
                                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                                  let myEmail = "eskimo" + "1" + "@apple.com"