1 Reply Latest reply on Jul 15, 2010 8:02 AM by VRPDeveloper

    Locale Selection Drop Down Menu label

    djh88ukwb Level 1

      Hello all, i am trying to get to grips with Localization with flex,  I have created my own files to be used, (.properties) files, and made a simple application that works.  It uses a dropdownlist to allow the user to select which language to view.

       

      Here is my code

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" viewSourceURL="srcview/index.html">
          <fx:Declarations>
              <fx:Date id="currentDate"/>
              <mx:DateFormatter id="df"/>
              <s:ArrayList id="locales">
                  <fx:String>en_US</fx:String>
                  <fx:String>fr_FR</fx:String>
              </s:ArrayList>
          </fx:Declarations>
          <fx:Style>
              @namespace s "library://ns.adobe.com/flex/spark";
              s|Label { font-size:18; }
          </fx:Style>
          <fx:Metadata>
              [ResourceBundle("customStrings")]
          </fx:Metadata>
          <fx:Script>
              <![CDATA[
                  import spark.events.IndexChangeEvent;
                 
                  protected function dropdownlist1_changeHandler(event:IndexChangeEvent):void
                  {
                      resourceManager.localeChain = [ locales.getItemAt(event.newIndex) ];
                      dateLabel.executeBindings();
                  }
              ]]>
          </fx:Script>
          <s:layout>
              <s:VerticalLayout horizontalAlign="center" paddingTop="20"/>
          </s:layout>
          <s:DropDownList dataProvider="{locales}"
                          change="dropdownlist1_changeHandler(event)"
                          selectedIndex="0"/>
          <s:Label id="dateLabel"
                   text="{resourceManager.getString('customStrings','todayItIs')} {df.format(currentDate)}"/>
          <s:Label text="{resourceManager.getString('customStrings','helloWorld')}"/>
          <s:BitmapImage source="{resourceManager.getClass('customStrings','helloFlag')}"/>
      </s:Application>

       

      The files used at the moment are "en_US" and "fr_FR" .  THe drop down populates using an array

       

              <s:ArrayList id="locales">
                  <fx:String>en_US</fx:String>
                  <fx:String>fr_FR</fx:String>
              </s:ArrayList>

       

      However in my dropdown menu it lists en_US and fr_FR, how can i change this to English and French ?  Whilst maintaining the ability to swap the lang files,

       

      Thanks !