9 Replies
      Latest reply on Apr 28, 2016 9:52 AM by cepages
      cepages Level 1 Level 1 (0 points)

        We are creating an app to be launch in different parts of the world. Currently the app is in English and we want to add a new Localization, Mexico.

         

        Because the app is getting data from different servers depending of the country, we have created different targets so we can decide each server url per target, this is also because not all countries have the same features ( same data to download ), so a Spanish user will get different content than a British user (this is more complex than simply data).

         

        Our plan is upload different targets in different App Stores, so if a Spanish Apple Store user downloads the app will download the app pointing to the spanish server, but if a British User downloads the app will download the app pointing to the UK server.

         

        Because the target selects the url, the Spanish server will provide data in Spanish and the British sever data English.

         

        So we'd like each target to set just one localisation, because of the localisation is in the project I can't find a way to do it.

         

        We don't want a situation where a Spanish user with his phone in English downloads the App from the Spanish Apple Store and gets half of the app in English (content locally) and other half in Spanish ( content from the server )

         

        Thanks

        Carlos

        • Re: Creating an app with multiple languages but one language per target
          eskimo Apple Staff Apple Staff (12,735 points)

          This could be tricky.  To start, a question: are you using base localisation?

          Share and Enjoy

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

            • Re: Creating an app with multiple languages but one language per target
              cepages Level 1 Level 1 (0 points)

              Hi eskimo

               

              Yeah, I'm using base localisation.

               

              Thanks

                • Re: Creating an app with multiple languages but one language per target
                  eskimo Apple Staff Apple Staff (12,735 points)

                  Yeah, I'm using base localisation.

                  That makes things especially tricky because, if you use English for your base localisation, there’s no way to remove English from your Spanish store build (and vice versa).

                  Have you tried playing around with CFBundleLocalizations?  It’s possible you could continue to ship both your base localisation (English, say) and your other localisation (Spanish, say) and then customise CFBundleLocalizations so that only English is listed in your UK store app and only Spanish is listed in your Spanish store app.  I’ve never tried to use CFBundleLocalizations to reduce the number of localisations, but it might work.

                  Share and Enjoy

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

                    • Re: Creating an app with multiple languages but one language per target
                      cepages Level 1 Level 1 (0 points)

                      Hi Eskimo,

                       

                      Thanks for your answer. So lets say I have two targets in my App. MyAppTarget and MyAppSpanishTarget.

                       

                      My project have both localizations, Spanish and English.

                       

                      In the plist file of my MyAppTarget, I added the key CFBundleLocalizations = en and in the plist file of my MyAppSpanishTarget, I added the key

                      CFBundleLocalizations = es.

                       

                      I take an iPhone with Spanish language and I run MyAppTarget, unfortunatelly the back buttons are still on Spanish.

                       

                      Is there anything I'm missing?

                       

                      When you were talking about the Apple Store:

                       

                      It’s possible you could continue to ship both your base localisation (English, say) and your other localisation (Spanish, say) and then customiseCFBundleLocalizations so that only English is listed in your UK store app and only Spanish is listed in your Spanish store app.

                       

                      Is only in the App Store where I can test the behaviour with CFBundleLocalizations?

                       

                      Regards

                      Carlos

                        • Re: Creating an app with multiple languages but one language per target
                          eskimo Apple Staff Apple Staff (12,735 points)

                          Is only in the App Store where I can test the behaviour with CFBundleLocalizations?

                          No.  In this context your day-to-day testing should be adequate to determine whether things are working or not.

                          In the plist file of my MyAppTarget, I added the key CFBundleLocalizations = en and in the plist file of my MyAppSpanishTarget, I added the key CFBundleLocalizations = es.

                          CFBundleLocalizations is meant to be an array.  Did you actually set it as a string?  Or are you using string syntax above purely for convenience?

                          Share and Enjoy

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

                            • Re: Creating an app with multiple languages but one language per target
                              cepages Level 1 Level 1 (0 points)

                              I set an array, for example this is the info.plist for MyAppTarget:

                               

                              (I hope you can see the screenshot, if not the structure is:

                               

                              Information Property List (Dict)

                              |-> CFBundleLocalizations (Array)

                                   |-> Item 0 (String) -> en

                              |-> CFBundleDevelopmentRegion (String) -> en

                               

                              When I run the app with a device in other language (like Spanish), the translations in files .string (Spain) are used for the device. As I understood it should force to use just English in this case.

                               

                              Thanks

                                • Re: Creating an app with multiple languages but one language per target
                                  eskimo Apple Staff Apple Staff (12,735 points)

                                  When I run the app with a device in other language (like Spanish), the translations in files .string (Spain) are used for the device.

                                  Yeah, it sounds like that this suggestion isn’t going to fly.  Bummer.

                                  Given the above, I think your only option is to actually build two different versions of the app.  You can do that in two ways:

                                  • via two different projects

                                  • via post processing the app

                                  Neither is much fun.  It’s especially not fun when you’re using base localisation because you don’t have a version of your UI with the non-base strings in it.  You might be able to address that using ibtool but, honestly, I’m starting to veer into the realm of speculation here.

                                  At this point I’m going to suggest that you open a DTS tech support incident so that you can discuss this with our localisation expert.  It’s possible that I’m missing something significant here and I’d hate for you to start out down the wrong path.

                                  Share and Enjoy

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

                                    • Re: Creating an app with multiple languages but one language per target
                                      cepages Level 1 Level 1 (0 points)

                                      Hi Eskimo

                                       

                                      Thanks for your answer again.

                                       

                                      About the two solutions you gave me:

                                       

                                      -> via two different projects:

                                      This one can be tricky because we need to update everything in each setting in each project (for example updating any dependency with CocoaPods). Also it doesn't seem the right solution because the only thing we need it's to be able to force the localisation per target, so creating different project for this it seems like a work around.

                                       

                                      -> via post processing the app

                                      I was playing with this solution too, I created a script in Build Phases that empties all the translations for other languages for example:

                                       

                                      find "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app" -path "*/fr.lproj/.strings" -exec sh -c 'echo > "{}" ' \;

                                       

                                      Here the problem is with default texts such us alerts for Calendar Access or notifications access or titles for default back buttons, etc...

                                       

                                      At the end I opened an issue in DTS tech support incident so we'll try to fix the problem in the right way.

                                       

                                      Regards

                                      Carlos

                                        • Re: Creating an app with multiple languages but one language per target
                                          cepages Level 1 Level 1 (0 points)

                                          After talking with the Apple Developer Technical Support the solution is to do the following:

                                           

                                           

                                          1. Use a different Info.plist for each target, then
                                          > set CFBundleDevelopmentRegion key to “en” for the English target, and to
                                          > “es” (or “es-MX") for Mexico target.
                                          >
                                          > 2. In the Run Script build phase, write a script to ensure that:
                                          > - The English target only contains Base.lproj and en.lproj, which contains
                                          > the English resources.
                                          > - The Mexico target only contains Base.lproj and es.lproj, which contains
                                          > the Spanish resources.
                                          >
                                          > With this, the system should be able to use the right default langauge for
                                          > your app. Please provide me a sample project if that doesn’t work. I’d take
                                          > a look here.

                                           

                                           

                                          It works except for the alert such as notifications and calendar access any idea how can I force that in the right language too.

                                           

                                          There is not solution for that so far.

                                           

                                          Thanks and enjoy