5 Replies Latest reply on Jun 8, 2009 8:59 AM by master.card

    Localize an application for image

    master.card Level 1

      Hi,

       

      I define localization resource on image like:

       

      Enlish:

      menu.admin.down=

      Embed("assets/en/administrator_down.gif")

       

      Koren:

       

      menu.admin.down=

      Embed("assets/ko/administrator_down.gif")

       

       

      My code like:

       

       

      <mx:Image source="@Resource(key='menu.server.down', bundle='lang')" />

       

      <mx:Label x="238" y="196" text="{resourceManager.getString('lang', 'menu.lang')}" />

       

       

      Label  is to display correct Koren, but image is still stay at Enlish, maay I know whaat problem on it?

       

       

      Thanks,

        • 1. Re: Localize an application for image
          _Natasha_ Level 4

          Hi,

          do you write correct?

           

          menu.admin.down=

          Embed("assets/en/administrator_down.gif")

           

          <mx:Image source="@Resource(key='menu.server.down', bundle='lang')" />

          • 2. Re: Localize an application for image
            master.card Level 1

            I can make sure it does not work for image. it seem to need to trigger to get it work. I have two code show this issue.

            First code, when language switch from English to Koren, label is changed, but image did not change to koren image.

             

            Second code, I add a state to create image. when language switch from English to Koren, then click button to switch to "create image" state, it will display correct koren image.

             

            Some one can figure out what happen, why it does not work for first situation?

             

            (First code)

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
            <mx:Metadata>
              [ResourceBundle("form")]
            </mx:Metadata>
               <mx:XMLList id="localeDD">
              <locale key="1" value="English" />
              <locale key="2" value="Koren" />
            </mx:XMLList>
            <mx:Script>
              <![CDATA[    
                  import mx.resources.ResourceBundle;
                        private static var rb:ResourceBundle;
               private function setLocale():void {
                var selectedLocale:String = localeDropDown.selectedItem.@key;
                if ("1" == selectedLocale) {
                 resourceManager.localeChain = ["en_US"];
                } else if ("2" == selectedLocale) {
                 resourceManager.localeChain = ["ko_KR"];
                } 
               }
              ]]>
            </mx:Script>

            <mx:ComboBox id="localeDropDown" x="329" y="165" editable="true" enabled="true"
              dataProvider="{localeDD}" labelField="@value" change="setLocale()"/>
            <mx:Label x="225" y="167" text="Select Locale" color="#FFFFFF" fontWeight="bold" fontSize="13"/>
            <mx:Label x="238" y="196" text="{resourceManager.getString('form', 'firstname')}"
              color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                <mx:Image source="@Resource(key='menu', bundle='form')"   />
            </mx:Application>

             

            (second code)

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
            <mx:Metadata>
              [ResourceBundle("form")]
            </mx:Metadata>
               <mx:XMLList id="localeDD">
              <locale key="1" value="English" />
              <locale key="2" value="Koren" />
            </mx:XMLList>
            <mx:Script>
              <![CDATA[    
                  import mx.resources.ResourceBundle;
                        private static var rb:ResourceBundle;
               private function setLocale():void {
                var selectedLocale:String = localeDropDown.selectedItem.@key;
                if ("1" == selectedLocale) {
                 resourceManager.localeChain = ["en_US"];
                } else if ("2" == selectedLocale) {
                 resourceManager.localeChain = ["ko_KR"];
                } 
               }
              ]]>
            </mx:Script>

            <mx:ComboBox id="localeDropDown" x="329" y="165" editable="true" enabled="true"
              dataProvider="{localeDD}" labelField="@value" change="setLocale()"/>
            <mx:Label x="225" y="167" text="Select Locale" color="#FFFFFF" fontWeight="bold" fontSize="13"/>
            <mx:Label x="238" y="196" text="{resourceManager.getString('form', 'firstname')}"
              color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                <mx:Button label="switch" click="currentState = 'createImage';" />
                <mx:Canvas width="100%" height="100%" id="home">
                
                </mx:Canvas>
                <mx:states>
                    <mx:State name="createImage">
                     <mx:AddChild relativeTo="{home}">
                      <mx:Image source="@Resource(key='menu', bundle='form')"   />
                     </mx:AddChild>
                    </mx:State>
                </mx:states>   
            </mx:Application>

            • 3. Re: Localize an application for image
              master.card Level 1

              I can make sure it does not work for image. it seem to need to trigger to get it work. I have two code show this issue.

              First code, when language switch from English to Koren, label is changed, but image did not change to koren image.

               

              Second code, I add a state to create image. when language switch from English to Koren, then click button to switch to "create image" state, then it display correct koren image.

               

              Some one can figure out what happen, why it does not work for first situation?

               

              (First code)

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
              <mx:Metadata>
                [ResourceBundle("form")]
              </mx:Metadata>
                 <mx:XMLList id="localeDD">
                <locale key="1" value="English" />
                <locale key="2" value="Koren" />
              </mx:XMLList>
              <mx:Script>
                <![CDATA[    
                    import mx.resources.ResourceBundle;
                          private static var rb:ResourceBundle;
                 private function setLocale():void {
                  var selectedLocale:String = localeDropDown.selectedItem.@key;
                  if ("1" == selectedLocale) {
                   resourceManager.localeChain = ["en_US"];
                  } else if ("2" == selectedLocale) {
                   resourceManager.localeChain = ["ko_KR"];
                  } 
                 }
                ]]>
              </mx:Script>

              <mx:ComboBox id="localeDropDown" x="329" y="165" editable="true" enabled="true"
                dataProvider="{localeDD}" labelField="@value" change="setLocale()"/>
              <mx:Label x="225" y="167" text="Select Locale" color="#FFFFFF" fontWeight="bold" fontSize="13"/>
              <mx:Label x="238" y="196" text="{resourceManager.getString('form', 'firstname')}"
                color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                  <mx:Image source="@Resource(key='menu', bundle='form')"   />
              </mx:Application>

              (second code)

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
              <mx:Metadata>
                [ResourceBundle("form")]
              </mx:Metadata>
                 <mx:XMLList id="localeDD">
                <locale key="1" value="English" />
                <locale key="2" value="Koren" />
              </mx:XMLList>
              <mx:Script>
                <![CDATA[    
                    import mx.resources.ResourceBundle;
                          private static var rb:ResourceBundle;
                 private function setLocale():void {
                  var selectedLocale:String = localeDropDown.selectedItem.@key;
                  if ("1" == selectedLocale) {
                   resourceManager.localeChain = ["en_US"];
                  } else if ("2" == selectedLocale) {
                   resourceManager.localeChain = ["ko_KR"];
                  } 
                 }
                ]]>
              </mx:Script>

              <mx:ComboBox id="localeDropDown" x="329" y="165" editable="true" enabled="true"
                dataProvider="{localeDD}" labelField="@value" change="setLocale()"/>
              <mx:Label x="225" y="167" text="Select Locale" color="#FFFFFF" fontWeight="bold" fontSize="13"/>
              <mx:Label x="238" y="196" text="{resourceManager.getString('form', 'firstname')}"
                color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                  <mx:Button label="switch" click="currentState = 'createImage';" />
                  <mx:Canvas width="100%" height="100%" id="home">
                  
                  </mx:Canvas>
                  <mx:states>
                      <mx:State name="createImage">
                       <mx:AddChild relativeTo="{home}">
                        <mx:Image source="@Resource(key='menu', bundle='form')"   />
                       </mx:AddChild>
                      </mx:State>
                  </mx:states>   
              </mx:Application>

              • 4. Re: Localize an application for image
                master.card Level 1

                I can make sure it does not work for image. it seem to need to trigger to get it work. I have two code show this issue.

                First code, when language switch from English to Koren, label is changed, but image did not change.

                 

                Second code, I add a state to create image. when language switch from English to Koren, then click button to switch to "create image" state, then it display correct koren image.

                 

                Some one can figure out what happen, why it does not work for first situation?

                 

                (First code)

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
                <mx:Metadata>
                  [ResourceBundle("form")]
                </mx:Metadata>
                   <mx:XMLList id="localeDD">
                  <locale key="1" value="English" />
                  <locale key="2" value="Koren" />
                </mx:XMLList>
                <mx:Script>
                  <![CDATA[    
                      import mx.resources.ResourceBundle;
                            private static var rb:ResourceBundle;
                   private function setLocale():void {
                    var selectedLocale:String = localeDropDown.selectedItem.@key;
                    if ("1" == selectedLocale) {
                     resourceManager.localeChain = ["en_US"];
                    } else if ("2" == selectedLocale) {
                     resourceManager.localeChain = ["ko_KR"];
                    } 
                   }
                  ]]>
                </mx:Script>

                <mx:ComboBox id="localeDropDown" x="329" y="165" editable="true" enabled="true"
                  dataProvider="{localeDD}" labelField="@value" change="setLocale()"/>
                <mx:Label x="225" y="167" text="Select Locale" color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                <mx:Label x="238" y="196" text="{resourceManager.getString('form', 'firstname')}"
                  color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                    <mx:Image source="@Resource(key='menu', bundle='form')"   />
                </mx:Application>

                (second code)

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
                <mx:Metadata>
                  [ResourceBundle("form")]
                </mx:Metadata>
                   <mx:XMLList id="localeDD">
                  <locale key="1" value="English" />
                  <locale key="2" value="Koren" />
                </mx:XMLList>
                <mx:Script>
                  <![CDATA[    
                      import mx.resources.ResourceBundle;
                            private static var rb:ResourceBundle;
                   private function setLocale():void {
                    var selectedLocale:String = localeDropDown.selectedItem.@key;
                    if ("1" == selectedLocale) {
                     resourceManager.localeChain = ["en_US"];
                    } else if ("2" == selectedLocale) {
                     resourceManager.localeChain = ["ko_KR"];
                    } 
                   }
                  ]]>
                </mx:Script>

                <mx:ComboBox id="localeDropDown" x="329" y="165" editable="true" enabled="true"
                  dataProvider="{localeDD}" labelField="@value" change="setLocale()"/>
                <mx:Label x="225" y="167" text="Select Locale" color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                <mx:Label x="238" y="196" text="{resourceManager.getString('form', 'firstname')}"
                  color="#FFFFFF" fontWeight="bold" fontSize="13"/>
                    <mx:Button label="switch" click="currentState = 'createImage';" />
                    <mx:Canvas width="100%" height="100%" id="home">
                    
                    </mx:Canvas>
                    <mx:states>
                        <mx:State name="createImage">
                         <mx:AddChild relativeTo="{home}">
                          <mx:Image source="@Resource(key='menu', bundle='form')"   />
                         </mx:AddChild>
                        </mx:State>
                    </mx:states>   
                </mx:Application>

                • 5. Re: Localize an application for image
                  master.card Level 1

                  I try to attached files, someone can help me?