3 Replies Latest reply on Mar 8, 2011 1:04 AM by MichaelBoo

    I18N and dataprovider

    mwoodpecker

      Hello,

       

      I'm trying to implement the internationlization for an application. The language should be changed at runtime that's why I use the resourceManger functionality of flex. My problem is that some of our app widgets liek comoboxes are using dataprovider in order to be filled. If I change the language these widgets are not updated. Here is some sample code:

       

      <mx:ComboBox id="combo" dataProvider="{comboArray}"/>

       

      the dataprovider is initialised in the onApplicationComplete method of the view


      comboArray = [{label:resourceManager.getString('language', 'form.value1.label'), data:"test1"},
      {label:resourceManager.getString('language', 'form.value2.label'), data:"test2"}];

       

      Can anybody give me a hint how to solve this issue or best practices?

       

      Regards,

        • 1. Re: I18N and dataprovider
          BhaskerChari Level 4

          Hi mwoodpecker,

           

          When you are changing the language of the application...try to rebuild the comboArray array and reset the dataprovider for your

          ComboBox.

           

          This will resolve the problem.

           

          Thanks,

          Bhasker

          • 2. Re: I18N and dataprovider
            JabbyPandaUA Level 3

            Add to all your instances of  combo box (DropDownList in Flex 4) the following:

             

            override protected function resourcesChanged() :  void {
                    var storedSelectedIndex : int = selectedIndex;
                    selectedIndex = -1;
                    selectedIndex = storedSelectedIndex;
                }
            

            • 3. Re: I18N and dataprovider
              MichaelBoo

              Hi!

               

              Did you find a solution ?

               

              Same problem for me.. I have a List component that is filled with ArrayList (or bindable variable). The label element have to be translate if  i push a button.

               

               <mx:ArrayList>
                 
              <fx:Object label="{resourceManager.getString('i18n', 'strawberry')}" data="0"/>
                 
              <fx:Object label="{resourceManager.getString('i18n', 'pear')}" data="1"/>
              </mx:ArrayList>

              What is inside my function when i push the button.

              ResourceManager.getInstance().localeChain = ["fr_CH"];

              Nothing is translated.... I already tried to use a [Bindable] variable with datas inside but still no reaction.

               

              In simple VBox is working...

               

              <mx:VBox id="testVBox" 
                 
              label="{resourceManager.getString('i18n', 'pear')}"
                 
              width="100%"></mx:VBox>


              Someone can help me please ?

              Thanks in advance.