Hello folks,
Let’s show how flex-mojos can be used to generate resource-bundles.
To start, I strongly recommend you read this.
This is a good start to understand how Runtime Localization work. And, with this in mind we can show how to use flex-mojos to create Runtime Localized applications.
Here you can get the source for FlightReservationSamples 1 and 2.
So, lets start from begging. Download FlightReservation1 Sample and import it to FlexBuilder.
In other to compile this Sample1 with flex-mojos, we need to add this pom:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>info.rvin.mojo</groupId>
<artifactId>flex-super-pom</artifactId>
<version>1.0-beta2</version>
</parent>
<groupId>com.adobe.flex.samples</groupId>
<artifactId>FlightReservation1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>swf</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>info.rvin.mojo</groupId>
<artifactId>flex-compiler-mojo</artifactId>
<configuration>
<sourceFile>FlightReservation1.mxml</sourceFile>
<mergeResourceBundle>true</mergeResourceBundle>
<resourceBundlePath>${basedir}/locale/{locale}</resourceBundlePath>
</configuration>
</plugin>
</plugins>
</build>
</project>
During this post I figure out flex-mojos will not be able to compile FlightReservation1.
Found a bug, issue on adobe, and post stop on the middle.
https://bugs.adobe.com/jira/browse/SDK-15453
I strongly believe is a bug because when I define locales en_US,ja_JP all appears in English. When I define ja_JP,en_US all appears in Japanese. Lets wait Adobe’s feedback.
Well, lets do to the second sample. Download it from here. Again, import it on FlexBuilder.
Another pom is required for this project:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>info.rvin.mojo</groupId>
<artifactId>flex-super-pom</artifactId>
<version>1.0-beta2</version>
</parent>
<groupId>com.adobe.flex.samples</groupId>
<artifactId>FlightReservation2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>swf</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>info.rvin.mojo</groupId>
<artifactId>flex-compiler-mojo</artifactId>
<configuration>
<debug>true</debug>
<sourceFile>FlightReservation2.mxml</sourceFile>
<mergeResourceBundle>false</mergeResourceBundle>
<resourceBundlePath>${basedir}/locale/{locale}</resourceBundlePath>
<locales>
<param>en_US</param>
<param>ja_JP</param>
</locales>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.adobe.flex.sdk</groupId>
<artifactId>framework</artifactId>
<version>3.0.0.3.0.0.477</version>
<type>resource-bundle</type>
<classifier>ja_JP</classifier>
</dependency>
<dependency>
<groupId>com.adobe.flex.sdk</groupId>
<artifactId>rpc</artifactId>
<version>3.0.0.3.0.0.477</version>
<type>resource-bundle</type>
<classifier>ja_JP</classifier>
</dependency>
</dependencies>
</project>
So, lets explain this pom.
sourceDirectory: define sources located at src directory.
mergeResourceBundle: when is false resource-bundle files are not merged into SWF, so, we got runtime resource-bundle.
resourceBundlePath: folder when .properties files are located. {locale} is replaced at runtime by locale
locales: define what locales should be generated.
So, running mvn clean install you will got 3 artifacts:
[INFO] [install:install]
[INFO] Installing D:\FlightReservation2\target\FlightReservation2-1.0-SNAPSHOT.swf to c:\repository\com\adobe\flex\samples\FlightReservation2\1.0-SNAPSHOT\FlightReservation2-1.0-SNAPSHOT.swf
[INFO] Installing D:\FlightReservation2\target\FlightReservation2-1.0-SNAPSHOT-en_US.swf to c:\repository\com\adobe\flex\samples\FlightReservation2\1.0-SNAPSHOT\FlightReservation2-1.0-SNAPSHOT-en_US.swf
[INFO] Installing D:\FlightReservation2\target\FlightReservation2-1.0-SNAPSHOT-ja_JP.swf to c:\repository\com\adobe\flex\samples\FlightReservation2\1.0-SNAPSHOT\FlightReservation2-1.0-SNAPSHOT-ja_JP.swf
One unlocalized swf and two resources swfs (one per locale).
In order to run that, all files must be copied into any HTTP server with html wrappers. I don’t know why, but runtime localization only run with html wrapper.
So, while flex-mojos doesn’t generate html wrapper, it can be download from here.
I just copy and rename swf files.
Both projects are available on SVN under it folder.
VELO