1 Reply Latest reply on Apr 30, 2011 2:20 AM by Chris Banford

    Localization of a multi- Native window app (Desktop)

    Chris Banford

      Hi list,

       

      Just a quick check to see if I'm missing something while trying to build an AIR + HTML app using Localisation...

       

      All is set up and working fine as long as I switch languages in my main app's window, but I'm not (yet) able to get my locale changes to show up in the app's other (Native) windows.

       

      That the locale switch is working in the main app window shows me that it does work, but that I'm probably missing some key piece of info for propagating changes out to the other windows (the local_innerHTML="xxx" fields all show up blank after calling update() ).

       

      In the other Native window's html, I'm including the <script type="text/javascript" src="/lib/air/AIRLocalizer.js"></script>

       

      In the Localization docs, it says that air.Localizer is a Singleton. My assumption would be that switching the app's locale would affect all currently opened and any future windows...

       

      ...is this assumption correct?

      Do I need to call air.Localizer.localizer.update() on each Native window separately? (Singleton per window instance?) If yes, anyone have a simple working example??

       

      Hope I'm explaining my issue semi-clearly! Happy to provide more details if req.

       

      Cheers,

      -Chris

        • 1. Re: Localization of a multi- Native window app (Desktop Javascript+HTML)
          Chris Banford Level 1

          Okay, to answer my own question:

           

          air.Localizer is a singleton *per* Native window instance (or this is my conclusion - no mention of anything related in the Adobe docs...)

           

          So to have a multi-window application update the language locale across all its windows, you'll need some sort of app-wide mechanism to manage this.

           

          Below is a little snippet that shows how to set the locale on a newly opened Native window (this would be in some sort of "onOpen()" method for the window).

           

                  var win = this._htmlLoader.window;
                  var chain = win.air.Localizer.localizer.getLocaleChain();

                  // change the language to German
                  win.air.Localizer.sortLanguagesByPreference( supportedLanguagesList, ['de'], null, true );
                  win.air.Localizer.localizer.setLocaleChain(chain);
                  win.air.Localizer.localizer.update();
                  air.trace(chain);

           

          Hope this helps someone in the future!

           

          Cheerio,

          -Chris