Skip navigation
ErikaDparit
Currently Being Moderated

How to switch between languages

Feb 15, 2012 11:08 AM

Tags: #change #switch #language #multilingual

Hello,

Im working on a Flash Catalyst application where I need to use 3 different languages as the language of the application (english-russian-italian).

What do I have to do in order for the language to change when any of these 3 buttons indicating the different language  is pressed by the user??

In other words, how can I change the language of the application from italian to english? (the change would have to be in the buttons and the texts showing in each state of the application).

Do I have to make 3 different applications with the 3 languages that I want so that when for example the IT button is pressed then the italian application should be loaded?

I think that this is not the best solution that someone should follow but I can't think of something else, since my coding abilities are very very limited.

I would really appreciate if someone could help me with this or give me a hint of where should I search for help.

 

Thank you in advance

Erika

 
Replies
  • Currently Being Moderated
    Feb 18, 2012 2:07 PM   in reply to ErikaDparit

    I think you should use of dynamic RichText. Then you create 3 buttons which changes language. When user select language, varible is creating at the same time (the type of varible: String). When application reads data from XML file, then URL changes into XML files with the value of varible. Example:

     

      [Bindable]

                        public var something:RichText;

     

     

      public var language:String;

                        private var _somethingData: XML = null;

                        private var _somethingService:HTTPService;

     

    public function loadSomething():void

                        {

                                  var date:Date = new Date();

                                  _somethingService = new HTTPService();

                                  _somethingService.url = "biografie/"+language+".xml".concat("?nochace=", date.time);

                                  _somethingService.resultFormat = "e4x";

                                  _somethingService.method ="GET";

                                  _somethingService.addEventListener(ResultEvent.RESULT, onResultLoadSomethingData);

                                  _somethingService.addEventListener(FaultEvent.FAULT, onFault);

     

                                  _somethingService.send();

                        }

     

                        private function onResultLoadSomethingData(event:ResultEvent):void

                        {

                                  somethingText.text = String(event.result.welcom[0].text);

                        }

     

                        private function onFault(event:FaultEvent):void

                        {

                                  Alert.show("error");

                        }

     

    Ofc you must create 3 XML files of 3 language version. But you can't create that code in Flash Catalyst, you must use Flash Builder.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2012 9:16 AM   in reply to ErikaDparit

    Jacob's solution is on the right track. There are two methods to solve this. One is to manually load an external file, then write the ActionScript (in Flash Builder) to update all the text in the app to the correct value. Another solution is to leverage the built-in localization capabilities in Flex. For this see: http://devgirl.org/2011/03/15/flex-4-localization/ for some guidance. It also requires Flash Builder and some work.

     

    Good luck!

    Chris

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 23, 2012 9:55 AM   in reply to ErikaDparit

    For your case, you are going to have to solve it via the brute force method of creating it 3 times. The graphics will be shared between all the versions (assuming you build it as one app). The only thing to warn you about is that, FC only supports 20 states. If you run out of states, you will need to create custom components to hold more states. See the forums for more on this.

     

    Good Luck,

    Chris

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points