3 Replies Latest reply on Apr 9, 2009 7:31 AM by thebouv

    Internationalization/Overriding label property?

    finallyanamethaticanuse

      I am new to Flex and have difficulties understanding something. I really appreciate any help that will come out of this.

       

      I have successfully copied/pasted and adapted the code found here: http://flexme.wordpress.com/2007/07/11/internationalization-in-flex/

      This solution seems to work great and I would really like to use this. When I make a formItem and set the label to

       

      Localizator.getInstance().gT('translateme')

       

      it all works great.When I click my language change button (currently only supports 2 languages), the label will show the same text in a different language.

       

      Now, I am basically trying to create a small framework of components I will reuse in my application. Now on top of all the form components, I want to subclass the FormItem, and override the label property, so I would be able to type


      <MyTextInput label="translateme"/>

       

      And the label would automatically be translated in the front-end.

       

      I've tried this with:

       

          override public function set label(aValue:String):void {
              super.label = Localizator.getInstance().gT(aValue);
          }

       

      And all variations on that, lke using a private variable _label and bind the super class to that variable. I tried some examples where an labelChanged event would be thrown from the setter which would be bound to the getter, etc. As I said, I am new to Flex, so I don't have a clue what I am supposed to do here.

       

      If I try to use this

       

      <MyTextInput label="{Localizator.getInstance().gT('translateme')}"/>

       

      And I have a breakpoint on my overridden setter, I notice that the setter does get called when clicking on my language change button, so this gives me the feeling that the binding gets lost when I override the setter myself (in the solution I want it to work in). Any suggestions on how to approach this?

       

      As I said, I am new to Flex so this might be a completely wrong approach and might never work at all. I'd really appreciate if someone can get me on the right track!

       

      Thanks for your time and consideration!