5 Replies Latest reply: Feb 28, 2012 2:05 AM by nam1490 RSS

    Localization

    nam1490

      I am trying to localize my application.i have used flex 3.4 and my application is air.and i am unable to use localization.can any any one tell me what i am missing in the following code?

       

       

      my property file is---

      en_US/RegistrationForm.properties

      registration_title=Registration

      submit_button=Submit Form

      personname=Name

      street_address=Street Address

      city=City

       

      and my actionscript file is--

      <?xml version="1.0"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

                <mx:Script>

       

       

                          <![CDATA[

                                    import mx.controls.Alert;

                                    import mx.resources.ResourceBundle;

                          ]]>

       

                </mx:Script>

                <mx:Form>

                          <mx:FormItem label="{resourceManager.getString('RegistrationForm','registration_title')}">

                                    <mx:TextInput/>

                          </mx:FormItem>

                          <mx:FormItem label="{resourceManager.getString('RegistrationForm','submit_button')}">

                          <mx:TextInput/>

                          </mx:FormItem>

                          <mx:FormItem label="{resourceManager.getString('RegistrationForm','personname')}">

                          <mx:TextInput/>

                          </mx:FormItem>

                                    <mx:FormItem label="{resourceManager.getString('RegistrationForm','street_address')}">

                          <mx:TextInput/>

                          </mx:FormItem>

                                              <mx:FormItem label="{resourceManager.getString('RegistrationForm','city')}">

                          <mx:TextInput/>

                          </mx:FormItem>

                </mx:Form>

      </mx:Application>

       

      Also i have set additional compiler argument as  -locale=en_US;

      please suggest any way.

      thanx in advance.

        • 1. Re: Localization
          GordonSmith Adobe Employee

          Inside <mx:Application>, add

           

          <mx:Metadata>

              [ResourceBundle("RegistrationForm")]

          </mx:Metadata>

           

          This tells the compiler that your application class uses a resource bundle named RegistrationForm. Without this metadata, the compiler won't understand that it also needs to compile your RegistrationForm.properties file. It's not smart enough to figure this out by looking at parameters of ResourceManager methods inside databinding expressions.

           

          Gordon Smith, Adobe

          • 2. Re: Localization
            nam1490 Community Member

            hi gordon ,

            if i add this mx:Metadata in application then the error occur like--

            Unable to resolve resource bundle "RegistrationForm" for locale "en_US".

            then what is the solution for that?

            • 3. Re: Localization
              nam1490 Community Member

              Also i am getting this error in case while compiling resource, by using command-

              mxmlc -locale=en_US -source-path=c:\myapp\locale -allow-source-path-overlap=true c:\myapp\TestLocalization.mxml

              please somebody suggest what i am doing wrorg.

              • 4. Re: Localization
                GordonSmith Adobe Employee

                Assuming that the source directory for your .mxml, .as, and .css files is C:\myapp\src and the en_US version of RegistrationForm.properties is in the directory C:\myapp\locale\en_US, then you should be specifying -source-path=C:\myapp\src,C:\myapp\locale\{locale}. And there should be no need to specify -allow-source-path-overlap=true; in general, you should avoid overlapping source paths.

                 

                Gordon Smith, Adobe

                • 5. Re: Localization
                  nam1490 Community Member

                  thanx a lot.