8 Replies Latest reply on Sep 25, 2006 4:38 PM by vrubba

    localization in fds

      I've managed to get localization working on a non fds flex app using the command line mxmlc compiler. That took a while in itself. Now I'm trying to do the same thing using fds. I've enabled the locale en-US in the flex-config.xml file and restarted the server. But when I go to run the app in flexbuilder I get this message:
      Multiple symbols named 'C:\fds2\jrun4\servers\default\samples\DSLessons\Bob.mxml'.
      I have several files in play here:
      I can get the same app to work not using fds. However I have no control over command line parameters for the compiler since this is handled by fds (from what I've been able to tell)
      I know the code itself and the file/folder layout is fine too. But there's little to no documentation on localization to begin with, and I haven't found anything implementing this on FDS2.
      I've tried adding the locale and/or the locale/en_US paths to the run... options | source but that didn't work either.
      I've also copied the contents of the en_US folder to a fr_FR folder in the frameworks/locale folder (that got my basic app working!)

      Please help!
        • 1. Re: localization in fds
          Hi, I'm not exactly sure why you are getting this error message. Can you try changing the name of your resource bundle? So change 'Bob' to 'BobRB' in Bob.mxml and then rename these files:




          Doing this may get rid of the error, but I'm guessing you'll actually still have a problem. I think you may be running into an existing issue with Flex Builder that's just showing up in a new form. Here's the Flex Builder bug:

          Flex Builder can show an error after updating a properties file. You'll know you are encountering this problem if you see an "Unable to resolve a class for ResourceBundle" error where the class mentioned ends with "_properties". Clean the project in order to remove the error.

          So if you get this new error after renaming the properties file, you're just going to have to live with this problem for the moment. Sorry- it will be fixed in the next release.
          • 2. Re: localization in fds
            vrubba Level 1
            hmm, ok let's dumb it down a bit. forget flex builder. ( i renamed the properties several times before I posted this... it made no difference)

            using just fds and notepad.exe...

            what do i need to do to create a simple mxml application hosted in fds that uses a resource file.
            It would be great if you could use the sample files from the flex dev guide (page 790), but with an fds slant.
            I want the languages included to be fr_FR and en_US
            I want just a simple mxml app that does hello world using a resource string.

            I'd like to know what changes have to be made to the flex config files on fds to tell it which language to use.

            this is critical to our application. We do realize the language cannot be changed at runtime, however I think from what I've read, that we can put different language versions in seperate app folders on the fds server, which is fine.

            I really appreciate the help.


            • 3. Re: localization in fds
              vrubba Level 1
              Ok I followed my own advice and started over and after a little bit of tweaking I got it working. Here's how.

              To create a working flex app hosted on fds2 we'll use the existing samples folder:

              Step 1. Set the locale and add the path
              In samples/web-inf/flex/flex-config.xml uncomment out the locale parameter:
              <!-- Specifies the locale for internationalization. -->
              <!-- not set -->
              <!-- -->

              and under source-path specify location of locale files:

              Ste 2. Create the sample app
              Create folder under samples called LocalApp
              In here create a file called Myapp.mxml which contains the following code:

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
              <mx:Label text="@Resource(key='hello', bundle='Myapp')"/>

              Step 3. Create the locale resource files

              Create a folder in LocalApp folder called locale
              In the locale folder create 2 folders called en_US and fr_FR
              In each of these folders create a file called Myapp.properties
              In each of these files add the line: hello=Hello WOrld! and hello=Salut le Monde (respectively)

              step 4. Run the app
              Make sure fds is running
              Open browser and enter the address:


              recompile=true is important if you want to change the flex-config.xml locale to fr_FR or
              modify the resource string files.
              Default behavior seems to be some serious caching which even a fds restart won't fix.

              Step 5. Change locale, refresh browser
              Open flex-config.xml and change the local parameter to fr_FR
              Save, then refresh browser.
              • 4. Re: localization in fds
                bdeitte Level 1
                Glad to hear it's working now! Can you tell me what you were doing when it wasn't working? I just want to make sure we enter any bugs if there are any here. It is very strange that you have to use "recompile=true", and that sounds like one bug.
                • 5. localization in fds
                  vrubba Level 1
                  The initial reason I couldn't get it to work is because I did not set a source-path variable that pointed to the locale/{locale} folder in the flex-config.xml - this was causing the rather obscure multiple symbols error.

                  As far as what might be an actual bug, well... in the Flex Build and Deploy.pdf on page 92, second last bullet point, it states:
                  "Invalidate all items in the client cache by making a change to the flex-config.xml file and
                  saving it. This file stores all the options that the web-tier compiler uses. When the file
                  changes, Adobe Flex Data Services recompiles the application SWF file the next time the
                  MXML file is requested."

                  I did not experience this. No matter what changes I made to flex-config.xml, the locale never changed.
                  Steps to reproduce:
                  1. Start FDS
                  2. Open the localization application in a browser without any querystring parameters.
                  3. Note the language of the hello world label.
                  4. Open the flex-config.xml and change the locale to the other one, i.e. from en_US to fr_FR
                  5. Save the flex-config.xml and refresh the browser
                  6. Note the language has not changed to new locale
                  7. Stop FDS and restart FDS
                  8. Refresh the browser, language should still be the same
                  9. Close the browser and reopen to same page. Language still the same.
                  10. Add the querystring ?recompile=true to the browser address
                  11. You will notice the app takes longer to load... and the locale will now be correct.

                  I found out about the recompile=true parameter in the same pdf, on page 93, second paragraph.

                  Hope that helps.

                  • 6. Re: localization in fds
                    vrubba Level 1
                    More information...

                    There's a flex-webtier-config.xml file that contains the following section:

                    <!-- specifies whether or not to use incremental compile -->
                    <!-- with incremental compile is true, when an mxml document is requested,
                    only that file and dependent files which have changed will recompiled.
                    with incremental compile is false, when an mxml document is requested,
                    that file and all dependent files are recompiled. -->

                    The default out of the box setting is true. If I change it to false I no longer need the ?recompile=true argument.

                    • 7. Re: localization in fds
                      bdeitte Level 1
                      Hi Victor, thanks for the information. That is definitely helpful. I know we've fixed one issue with incremental compilation and resource bundles after the release, but I'll enter this as a bug as well so that we're sure it's fixed for the next release.
                      • 8. Re: localization in fds
                        vrubba Level 1
                        Someone sent me a private message the other day and I'm going to post my reply in here for anyone else that might stumble upon this. Also, in case I'm wrong one of you adobe guru's can correct me :)

                        A multi-language flex app:

                        Basically, you have to indicate which language you wish to use at compile time. So if you wish to support 3 languages, you will need to define 3 locales - and then compile 3 swf files and then use an html/javascript wrapper to detect browser region/language and then redirect the user to their respective swf.

                        When you create a project in flex you have 3 options - basic, fds with server compile and fds with flexbuilder compile.

                        In a basic app you can access the compiler command arguments by going to project properties and selecting Flex Compiler. You will see the words -locale en_US . To compile your basic app with a different language, change this line to something like -locale fr_FR.

                        In a fds project where flexbuilder does the compiling ( compile application locally..) you have access to the compiler arguments in the exact same place as a basic project.

                        In an fds project that is compiled on the server, Flexbuilder no longer has any control over the compiler arguments... This is the only time the flex-config.xml determines what the compile arguments will be. That's why the Flex Compiler screen is greyed out in Flexbuilder. Again you would change the locale tag to the one you want i.e. fr_FR in flex-config.xml and then compile.

                        As far as folders goes.. for fds applications... you would reference the string using this syntax:
                        <mx:Label text="@Resource(key='hello', bundle='Localization')"/>
                        Then you would create the correpsonding resource file in a subfolder called locale\fr_FR\Localization.properties with a list of strings formatted like:
                        hello=Hello World!!
                        Finally, you would need to make a copy of the web-inf\flex\locale\en_US folder in web-inf\flex\locale\fr_FR