12 Replies Latest reply on Jan 15, 2013 7:57 AM by sinious

    How do I add localization to an iOS app?

    rachalmers

      I see in the tab that I can select multiple languages to release an iPhone/iPad app in, using CS6 + AIR, and there are lots oftutorials for localizing using XCode - but are there any for FlashPro? Tutorials? HowTos etc

      I could really use some pointers on this

      Thanks

        • 1. Re: How do I add localization to an iOS app?
          sinious Most Valuable Participant

          Here's some Adobe AIR localization information to get you started:

          http://help.adobe.com/en_US/AIR/1.5/devappsflex/WSB2927578-20D8-4065-99F3-00ACE6511EEE.htm l

           

          The strategy depends on if you plan to use Flex or not. You said Flash Pro so I'll assume you mean a pure Timeline/AS project.

           

          In that case take a look (in that link) at the Localizing HTML section in the "Defining resource bundles" subsection especially. Some form of key=value method will be what you opt for. What you wrap that in is up to you. It can be anything from sqllite DB, CSV, XML, JSON, etc.

           

          You'll use the Capabilities.languages array at index 0 to determine the current language of the device. Based on that, load the correct bundle with the language desired and repopulate the whole app with that text. Be careful to choose fonts correctly based on the locale to assure they have the capabilities (such as Chinese multi-byte characters). 

          1 person found this helpful
          • 2. Re: How do I add localization to an iOS app?
            rachalmers Level 1

            @sinious

            Thanks for that. It looks reasonably clear, and ther are a couple of (old) tutorials out on the internet I have been browsing.

            So that's an excellent start.

             

            Let me be more specific I guess about what I'm using.

            - CS6 Flash Pro + Update2. so the app core is .fla + .as Using the iOS template iPhone/iPad app building. I am now on the Mac with it so I can attatch to the iPhone/iPad Simulator.

            - AIR SDK, as well as Flex SDK. The app is using calls to various parts of both of them. Embedded image as backgrsound, and stageWebviews and so on.

            Anyway, the app worsks beautifully, with refinements being done from time to time. The next project is to localize it, so I can have it operable in any of the generally available languages. As one does ...

             

            The odd thing maybe is that the 2 of the stageWebviews are of course HTML on the device, so will need to be delt with in their own way.

             

            Flash Pro has the tab to select what languages the program will use, along with the Deployment, and Icons tabs. That's what started this all off. I know there is more to it than just selecting a couple of buttons in a tab - but things do improve as we go no doubt.

             

            thanks

            • 3. Re: How do I add localization to an iOS app?
              rachalmers Level 1

              Found the whoe deal, for the NEW CS6 Flash Pro.

               

              http://helpx.adobe.com/flash/topics.html

               

              I do wish this stuff was easier to find.... but thanks, it was your pointer that put me on the right trail.

              • 4. Re: How do I add localization to an iOS app?
                sinious Most Valuable Participant

                By using the Strings panel you're ultimately doing the identical thing, only it can actually be more work. A few things to note.

                 

                In both situations, manually handling languages or using String:

                 

                - You need to create all dynamic TextFields with a unique ID

                - You need to assign specific text to that field

                - An XML file is typically used

                - Fonts are decided based on the language

                 

                The differences are, with Strings panel:

                 

                - Each TextField needs to be assigned a default language

                - Each String needs to have a unique String ID assigned to it

                - The Strings panel is alphabetical (very hard to work with, especially with paragraph data)

                - The TextField needs a specific String ID assigned to it

                - You don't need to sniff the language, the system codePage will assign the correct text for you

                 

                With your own XML setup:

                 

                - XML can be formed in a much more friendly format (separated by sections, grouped intelligently, etc)

                - You will need to read the default language to load the proper XML text

                - IDs or an "order" to the XML will need to be implemented to assign the correct text to a TextField

                 

                The Strings panel is pretty common on many large scale languages, like c#, it's just not as simple and needy.

                 

                Being you actually have just as much (or more) work to use the Strings panel because text is sorted alphabetically it can be a real pain to find the text you're looking for. Does your paragraph start with "The" or any other common word? Ugh, go search through all the paragraphs/phrases/etc starting with "The" until you find it. Very illogical.

                 

                I like to set my own projects up with a XML structure that contains sections to group similar text. e.g.

                 

                <Text lang="en-us">

                     <MainMenu>

                          <Item id="0">Menu item 1</Item>

                          <Item id="1">Menu item 2</Item>

                     </MainMenu>

                     <AboutUs>

                          <Title>About Us</Title>

                     </AboutUs>

                </Text>

                etc..

                 

                Therefore when I read my code I can easily find the section I want to adjust text for, in the order I assign it, and code looks sensible and natural as well:

                 

                title_txt.text = langXML.AboutUs.Title.text();

                 

                Just throwing it out there before you get too heavily invested in thinking the Strings panel is ideal, less work or best practice. It's just easy for designers.

                1 person found this helpful
                • 5. Re: How do I add localization to an iOS app?
                  rachalmers Level 1

                  I've decided to use the

                  Other Panels -> Strings

                  as the way to go. It allows me to edit and add to the xml files easily for the translations.

                  strings.png

                  Note the word German in the de column, and Japanese in the ja column. Just there to remind me boldly, that they are there.

                   

                  The tab in the interface that I can't figure out anyway is this one following, But I've set it to the languages I am supporting anyway, just to see if anything happens.??? as I'm building only for iPhone/iPad I don't think it will make a difference anyway. Except perhaps when I want to write something on the web page in stageWebview. It isn't explained anywhere that I can find.

                  languages.png

                   

                   

                  The latest mystery is this one. As I'm not using XCode (yet) so don't have access to the ios 6 SDK, I'm now wondering what I do about this message ....

                   

                  Invalid Launch Image - Your app contains a launch image with a size modifier that is only supported for apps built with the iOS 6.0 SDK or later.

                   

                  Now, CS6 Flash Pro just doesn't have access to the iOS xxx SDK at all. What a pain. Now I have to go rename the launch icons.

                  • 6. Re: How do I add localization to an iOS app?
                    sinious Most Valuable Participant

                    The languages tab sets a simple value in XML for your app descriptor. It tells iTunes what languages your app supports. It sets this:

                     

                    <!-- Languages supported by application. Only these languages can be specified. -->

                    <!-- <supportedLanguages>en de cs es fr it ja ko nl pl pt ru sv tr zh</supportedLanguages> -->

                     

                    so for you:

                     

                    <supportedLanguages>en de ja</supportedLanguages>

                     

                    The launch images changes sometimes with the new iOS updates. Due to device size changes there is sometimes differences in the icon/launch image sizes. For iOS6 on iPhone (for example) you should have:

                     

                    Default~iphone.png

                    Default@2x~iphone.png

                    Default-568h@2x~iphone.png

                     

                    Log into the iOS developer section and read up on the SDK requirements.

                    1 person found this helpful
                    • 7. Re: How do I add localization to an iOS app?
                      rachalmers Level 1

                      Ar Ha. I see it all. Too easy, now I know where to look :-) Can I show my age by saying I grok that!

                       

                      as for the images - I'm of course using CS6 Flash Pro, and that's actually exactly what I have for my images,

                      Default~iphone.png

                      Default@2x~iphone.png

                      Default-568h@2x~iphone.png

                       

                      having followed their design notes to the letter. But that message of theirs indicated that as it hadn't been built with the 6.0 SDK, only available under XCOde and not CS^ ... they didn't want to know about the naming conventions.

                       

                      I have just rebuilt the app using simple names with sizes ie; Default640x1136.png names. According to their docs, the platform there is smart enough to see the image sizes and put the appropriate ones in the right place. We'll see. I'm fully expecting the binary to be rejected again.

                       

                      but that's ok. I'm struggling to get localization built in now. Starting with the three I mentioned, plus Chinese Simplified. xml files done, just have to get AS3 controlling it now. Getting there. I should have learnt about Locale a long time ago. The things one puts off..

                      • 8. Re: How do I add localization to an iOS app?
                        sinious Most Valuable Participant

                        I build in Flash Builder which tends to have a lot less issues while using ADT a bit more flexibly so I don't see this issue but you're always free to use a command line compile.

                         

                        Take look at this thread (note the file attached in the message marked correct, scroll down):

                        http://forums.adobe.com/message/4736090

                        • 9. Re: How do I add localization to an iOS app?
                          rachalmers Level 1

                          Ah well. I knew it wasn't going to be easy, though it should be... anyone have any ideas.

                           

                          This has me stumped. There is of course a lot of code above and below this, but the problem is this error; I really hate Error #1010 it's always so difficult to trace. hmm ok, should probably move the thread.

                           

                          TypeError: Error #1010: A term is undefined and has no properties.

                          at fl.lang::Locale$/loadXML()

                          at fl.lang::Locale$/loadLanguageXML()

                          at PinPointPremium()[C:\Users\Robert\Flash Development\PinPoint 6.5\Classes\PinPointPremium.as:273]

                           

                           

                          This is the code section - and the offending line at 273 is in BOLD and underline

                          ====================  first block ==========

                          // Checking for LocaleID for globalization.

                                var localeName:String= LocaleID.DEFAULT;
                                      var strTool:StringTools = new StringTools(localeName);
                                      var nf:StringTools = new StringTools(localeName);
                            
                                      trace('\n\n' + "LocaleID requested: " + nf.requestedLocaleIDName + "; actual: " + nf.actualLocaleIDName);
                                      trace( "Last Operation Status:" + nf.lastOperationStatus ); 
                          //************************ this first block works ****************
                             
                                         Locale.setLoadCallback(localeCallback);
                                        Locale.loadLanguageXML("en");    <---------------- line 273
                              function updateText(success:Boolean):void {
                               var arr = Locale.stringIDArray;
                               for (var i = 0; i < arr.length; i++) {
                                this[arr[i]].text = Locale.loadString(arr[i]);
                               }
                              }
                                  function localeCallback(success:Boolean):void {
                               trace("en is loaded ");
                               }

                          • 10. Re: How do I add localization to an iOS app?
                            sinious Most Valuable Participant

                            Couple things come to mind. I did notice someone unhappy that only en-gb and en-us were supported for English variants in a random thread a while ago. Even though I see in the docs it loads "en" alone, are you sure this has not been updated to require the type of English?

                             

                            That aside, to manually set a direct reference to "en" (and avoid the formerly mentioned issue entirely) you can set the locale file explicitly.

                             

                            e.g.:

                            Locale.addXMLPath("en", "locale/locale_en.xml");

                             

                            Perhaps define that path and see if it works for you.

                             

                            Outside that, to really narrow down if the error spilled from the line above to the line below (callback issue), add a trace and some newlines between the error line and the line above it. Make sure that line is definitely at fault.

                            • 11. Re: How do I add localization to an iOS app?
                              rachalmers Level 1

                              Thanks sinious, I'm on it. Been a long day, snowing like crazy outside now, and it's nearly time for the end of this day.

                              I've had too much code stuffed in in bits. Getting it all mixed up.

                               

                              I will try the Path addition though. The error has gone away - but it cant hurt to force the location though.

                               

                              I'm not actually using a Flash stage - well, a blank stage I guess. But no timeline.

                              Load the fla, black, load an embedded image to fill  the screen, and placing AS3 generated buttons and stageweb views on that background.

                              As it's the iPhone/iPad, it's language will be fixed by who ever owns the phone. So I only need to grab the Default locale as it sees it.

                              Then load that from it's xml file.

                              The biggest headache is that I'm converting my already hardcoded button texts to now load from xml language files.

                              I've already run into the en-GB en-US en-AU problem ... So I want to force the app to read just en as the Locale if indeed it is any sort of English in the default at all. That should be ok.

                               

                              Everyone seems to be using Flash, with AS3 in the containers.

                              I'm using AS3 with just a basic Flash stage to hold it all in place.

                               

                              anyway, thanks for your help. Much appreciated.

                              • 12. Re: How do I add localization to an iOS app?
                                sinious Most Valuable Participant

                                If you want to force it, that code should do it.

                                 

                                Yes, converting every single place Text appears into dynamic TextFields is really the largest part of the work. The Strings panel or your own custom XML solution for localization is really the easier part. If you really want to use the Strings panel and use mostly predefined/created assets from the library then take the time to assign all those dynamic TextFields to a string ID from the Strings panel so they auto-update. That's about the only advantage at all about the Strings panel.

                                 

                                If it all works out please mark the thread answered so we can filter unanswered questions. Thanks and good luck!

                                1 person found this helpful