5 Replies Latest reply on Jan 13, 2010 10:04 AM by cheftimo

    Error formatter when change language by resourceManager.


      I had a problem when use resourceManager to change another language (no english); It causes errors for validating number, datetime; it can't format data correctly; so I can't format and validate data correctly when use Formatter( NumberFormatter, DateFormatter)

      Here the error I found with DateFormatter

      "Cannot access a property or method of a null object reference.

      at mx.formatters::DateBase$/get http://www.adobe.com/2006/flex/mx/internal::defaultStringKey()[C:\autobuild\3.2.0\framewor ks\projects\framework\src\mx\formatters\DateBase.as:173]

      at mx.formatters::DateFormatter$/parseDateString()[C:\autobuild\3.2.0\frameworks\projects\fr amework\src\mx\formatters\DateFormatter.as:156]
      at mx.formatters::DateFormatter/format()[C:\autobuild\3.2.0\frameworks\projects\framework\sr c\mx\formatters\DateFormatter.as:544]"


      Please help me!Thanks.

        • 1. Re: Error formatter when change language by resourceManager.
          cheftimo Level 2

          Do you have the appropriate 'sdks\3.1.0\frameworks\locale' folder for whatever locale/language you are working with?



          1 person found this helpful
          • 2. Re: Error formatter when change language by resourceManager.
            The_Milky_Way Level 1

            Thanks for your help!

            I created my language folder the same place with english folder(en_US) and It showed language correctly for label, button, alert.... when I change locale; But It caused errors when I validate and format data using DateValidation, DateFormatter, NumberValidation, NumberValidator.

            I have written the following test:


            <?xml version="1.0" encoding="utf-8"?>
            xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
            <mx:NumberValidator source="{testInput}"
            property="text" minValue="0" domain="real"
            trigger="{testInput}" triggerEvent="change"
                    private var testValid : Boolean = true;

                        private function init():void{

                        private function changeLocale(locale:String):void{
            <mx:ApplicationControlBar width="400">
            <mx:Label text="{resourceManager.getString('myResources','TITLE')}"  width="100%"/>
            <mx:Button label="eng" click="changeLocale('en_US')" />
            <mx:Button label="ita" click="changeLocale('it_IT')" />
            <mx:TextInput text="" id="testInput" width="40" />

            //with the following resources

                 * ...
                 * @author Sebastian Müller

            public class Languages
            import mx.resources.IResourceManager;
            import mx.resources.ResourceBundle;

            public function Languages() {}
            public static function setResources(resourceManager:IResourceManager):void{

            var myResources:ResourceBundle=new ResourceBundle("en_US","myResources");

            =new ResourceBundle("it_IT","myResources");




            Now the following error occurs. When I start the application my number validation works as expected. When I afterwards switch to italian the number validator don't work anymore.


            Do the following steps


            1. Type in a number in the text field
            2. Switch to italian
            3. Type in a letter => the text field does not turn into red


            Any ideas?

            • 4. Re: Error formatter when change language by resourceManager.
              JabbyPandaUA Level 3

              Hi The Milky way,


              Why have not you tried to "google" your runtime exception data, sometimes it is helpful


              Here is answer to your problem:



              I've created an related issue at Adobe JIRA 4 months ago, if you consider this issue to be important, please go to JIRA and vote


              "dateFormat" value from "SharedResources.properties" should not be shared between DateFields and DateFormatters


              • 5. Re: Error formatter when change language by resourceManager.
                cheftimo Level 2

                Hello,Milky Way:


                This thing is not as complicated as it looks. You need to do 2 things:


                1. Read this: http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_7.html.


                2. It would be good if you have a real 'it_IT' locale folder (not just one made by copying 'en_US' and renaming the copy). I do some work with Spanish and a couple of problems I had disappeared when I got a real es_CO resource.





                1 person found this helpful