Flex 3 Localization

ActionScript, Flex, tips 'n tricks 7 Comments »

With Flex 3 comes the ability to do runtime localization. Compared to Flex 2 where you actually had to recompile your application for each locale, you can now have one version of your application that contains different resource bundles.

Today I implemented this in one of the applications we are working on and ran into some issues. Here is how I got it to work in a nutshell. (Note: for a full instruction on implementing localization in Flex 3, I recommend the article Flex 3:Feature Introductions: Runtime Localization by Gordon Smith.)

- create a folder in your project to store your resource bundles (e.g. "locale")
- create a subfolder for each locale you want to implement (e.g. "locale\nl_BE" and "locale\fr_BE")
- in the locale subfolder, create a resources.properties file and save it as UTF-8
- enter the resources in the form of "key=value", like Ant property files
- update the compiler settings: -locale=nl_BE,fr_BE -source-path=locale/{locale}

You now also need to create localized framework resources. To do this, take the following steps:

- open a command line (run as administrator in Vista!)
- go to the "bin" folder in your Flex SDK installation folder
- run the copylocale.exe tool for each locale, this will copy the localized framework files from one locale to another (copylocale en_US nl_BE)
- check FLEX_HOME\frameworks\locale to see if the folder for your new locale has been created
- if you get an error "could not find resource bundle charts", search for a file called charts_rb.swc and copy it to the new locale folder in FLEX_HOME\frameworks\locale

A simple example of asking for a localized string:

Actionscript:
  1. // tell the compiler what resourcebundle to use
  2. <mx:Metadata>
  3.   [ResourceBundle("resources")]
  4. </mx:Metadata>
  5.  
  6. // if you are in a subclass of UIComponent
  7. var myString:String = resourceManager.getString("resources", "myKey");
  8.  
  9. // ...or if you are not in a subclass of UIComponent
  10. var myString:String = ResourceManager.getInstance().getString("resources", "myKey");

You can put these calls in a binding expression and switch your locale at runtime by setting the localeChain property on the resourceManager:

Actionscript:
  1. resourceManager.localeChain = ["nl_BE"];

That's about it. Have fun!


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Cruise Control and SVN over HTTPS

cruise control, tips 'n tricks No Comments »

When adding Prana to our Cruise Control system via the web dashboard, I ran into the following svn error:

svn: PROPFIND request failed on '/svnroot/prana/trunk'svn: PROPFIND of '/svnroot/prana/trunk': Server certificate verification failed: issuer is not trusted (https://prana.svn.sourceforge.net)

The problem is that a checkout over https requests the verification of a server certificate which is not handled in the web dashboard interface.

The solution

Make sure you have a user where the cruise control service is running under. Then log in to the build server with that user and manually checkout the repository with the following command...

svn checkout https://prana.svn.sourceforge.net/svnroot/prana/trunk c:/progra~1/cruisecontrol/projects/prana

... then press 'p' to accept the certificate permanently. You can now go back to the web dashboard and create the project.


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login