Reputation: 790
I'm trying to localize my Flex app, I have been able to setup the locale specifics and all the stuff inside MXML tags, that works pretty well, my question is, what about if I have for example:
if(loggin){
loginBtn.label = "Logout";
}else{
loginBtn.label = "Login";
}
How can I change with ActionScript those two strings to an other locale?
Thanks for any help!!
Upvotes: 0
Views: 253
Reputation: 29280
Use the ResourceManager
if(loggin){
loginBtn.label = resourceManager.getString(MyResourceBundles.LABELS,'login')
}else{
loginBtn.label = resourceManager.getString(MyResourceBundles.LABELS,'logout')
}
The downside of this approach is that bindings won't fire if the user changes language midway.
Therefore, for this specific example, I'd reccommend states:
<s:Button id="loginBtn"
label.loggedIn="{resourceManager.getString(MyResourceBundles.LABELS,'login')}"
label.loggedOut="{resourceManager.getString(MyResourceBundles.LABELS,'logout')}" />
Upvotes: 1