Archive for category resource bundle

Substitution Tokens in Resource Bundle Strings in Flex

There’s many times where you want to use a Resource Bundle String in-conjunction with variable data. People often breakup the RB String into 2 pieces like so:

part1=My name is
part2=and I like

And then put it back together in AS like:

var part1:String = ResourceManager.getInstance().getString('Labels', 'part1');
var name:String = "Brian Riley";
var part2:String = ResourceManager.getInstance().getString('Labels', 'part2');
var likes:String = "beer.";

var myStr:String = part1 + " " + name + " " + part2 + " " + likes;

Which works, but it’s a lot of unnecessary code. Take advantage of the tokens allowed in RBs and do the following:

likes=My name is {0} and I like {1}

var likes:String = ResourceManager.getInstance().getString('Labels', 'likes', ["Brian Riley", "beer."]);

The ResourceManager class will automatically substitue the tokens {0} and {1} in order and replace them with the array of strings provided as the last param in the getString() method.

Much simpler, right?

Post to Twitter Tweet This Post

, , , , ,

No Comments

Some Thoughts On Internationalization in Flex

Looking to develop a list of best practices for making the internationalization process of Flex apps go smoothly.

So, here goes!

  • Resource files need to be in UTF-8 format when you create them. That’s when you create them. If you put characters in a file such as an accent grave and THEN try to save as UTF-8, the saving process will munge the character. (Note: this is when working within the Eclipse IDE)
  • Adobe doesn’t seem to want to supply the language references for you except for en_US and ja_JP. You need to build them for all of the frameworks side stuff as well as for your own implementations. And when you change versions of FB, guess what? You gotta do it all over again. I suppose you could try just copying…..no, forget that.
  • Don’t expect that third party libs you use will have the language references you need. Hopefully, you’ll be able to get their source resource file and be able to translate and then build.
  • Make sure the font sets you’re using support the languages/characters you’re using.
  • Do read this excellent article.
  • …more to come

Post to Twitter Tweet This Post

No Comments

Configuring Eclipse/Flex for Building Resource Bundles

o Determine which sdk FB is using by looking through the compiler in properties
o Go to the root of the sdk
o Note: if you have dataviz, you’d need to copy fbpro from older rev to new rev
o Go into fbpro/projects you’ll see three folders, copy all three
• Copy them to sdk/frameworks/projects
o Go into the datavisualization folder you just dropped
• /bundles/en_US and create a folder called src
• copy the three .properties files from /bundles/en_US into src to source folder you just created
o Then run copylocale

-resource-bundle-list=resources.txt

bundles = containers core effects skins styles

mxmlc -locale=fr_FR,en_US -source-path=locale/{locale} -include-resource-bundles=containers,core,effects,skins,styles,charts,datamanagement -output fr_FR_ResourcMod.swf

Post to Twitter Tweet This Post

No Comments