Skip to main content
March 6, 2014
Question

Refresh (reload) content after language change

  • March 6, 2014
  • 1 reply
  • 332 views

Hi,

My mobile app supports different languages and also the option to select language at the settings screen. Obviously, all the text fields and buttons need to be 'refreshed' in order for the new language to take effect. What would be the best way to do it? I thought about reloading the app's main content but I could not find any info on how to do that with mobile AIR app.

Thanks in advance.

This topic has been closed for replies.

1 reply

Inspiring
March 11, 2014

You could set language phrases on bindable variables. Then link the text components to them. Any language change redefines the value of the variables, instantly modifing your labels, textareas, etc..

Example:

// On a data model (you could set the whole class as bindable)

// Define different language labels

[Bindable]

public var labelUsername:String;

[Bindable]

public var labelPassword:String;

// On an action controller

// This action modifies current language

protected function changeLanguage(newLanguage:String):void

{

     switch(newLanguage)

     {

          case 'english':

               langModel.labelUsername = 'Username';

               langModel.labelPassword = 'Password';

               break;

          case 'spanish':

               langModel.labelUsername = 'Nombre de usuario';

               langModel.labelPassword = 'Contraseña';

               break;

     }

}

// On a view, the text component

<s:Label text="{langModel.labelUsername}" />

This way, anytime you call the "changeLanguage()" method, the label will reflect the changes inmediatly.