support for i18n locales

tgoeke's Avatar


22 Aug, 2012 09:55 PM

I have not seen a specific example of how to do locales; is there an example of locales somewhere assuming GradleFX supports them?

  1. Support Staff 1 Posted by Maxime Cowez on 22 Aug, 2012 10:49 PM

    Maxime Cowez's Avatar

    Locales are supported. Have a look at the wiki's conventions page: you'll find the properties localeDir and locales explained there.

    As for an example: you can find one at
    This build script explicitly sets both those properties.

    Their default values are:

    • localeDir = 'src/main/locale'
    • locales = []
  2. 2 Posted by tgoeke on 23 Aug, 2012 02:57 PM

    tgoeke's Avatar

    Awesome! Thanks.


  3. 3 Posted by tgoeke on 24 Aug, 2012 10:09 PM

    tgoeke's Avatar

    Hey GradleFx wizards,

    I have gotten locales compiling, but I'd like to have localized swf outputs for each locale, i.e. if I'm building fancyApp.swf I'd expect some kind of output like



  4. Support Staff 4 Posted by Yennick Trevels on 25 Aug, 2012 09:59 AM

    Yennick Trevels's Avatar

    This is a rather special case you have there :)

    You can do this by creating dynamic compile tasks which extend from the GradleFx Mxmlc task, one for each locale. Then you create a compileAll task which depends on these dynamic compile tasks.
    The flexConvention property is a public property of the Mxmlc task which contains all the convention properties.

    def localeNames = ["en_US", "nl_NL"]
    localeNames.each { localeName ->
        task("compile_${localeName}", type: org.gradlefx.tasks.compile.Mxmlc) {
            doFirst {
                flexConvention.locales = [localeName]
                flexConvention.output = "${}-${localeName}"
    localeNames.each { localeName ->
        compileAll.dependsOn "compile_${localeName}"
  5. Support Staff 5 Posted by Maxime Cowez on 25 Aug, 2012 05:30 PM

    Maxime Cowez's Avatar

    Nice approach, Yennick.

    Alternatively, you could pass the locale as an argument to your build script. If your script is something like:

    locales = [locale]
    output = "${}-${locale}"

    You should be able to build each one of the swf's with the following command:

    gradle build -Pen_US
    gradle build -Pfr_FR

    The ´-P´ flag indicates a parameter.
    Warning: untested idea!

  6. 6 Posted by Tim Goeke on 29 Aug, 2012 01:40 AM

    Tim Goeke's Avatar

    Thanks Yennick,

    Your sample worked, almost. I'm porting over a working ANT build. The gradle build does build, but the resulting SWFs do not load properly in our internal Flex environment.

    The relevant ANT chunks are:

      <mxmlc-macro file="'${SRC_DIR}'/ourmodule.mxml">
         <arg line="-source-path+='${SRC_DIR}'"/>
         <arg line="-source-path+='${SRC_DIR}'/locale/{locale}"/>
         <arg line="-resource-bundle-list='${BUILD_DIR}'/" />
         <arg line="-output='${WAR_DIR}'/ourmodule.swf"/>
         <arg line="-locale=en_US" />
         <arg line="-source-path+='${SRC_DIR}'/locale/{locale}"/>
         <arg line="-output='${basedir}'/swf/target/locales/ourmodule-en_US.swf"/>
         <arg line="-include-resource-bundles ${bundles}" />

    Which eventually gets added to a war in which I get:

    /ourmodule.swf /locales/ourmodule-en_US.swf ... and so on ...

    The macro def is as follows:

      <attribute name="file" default="" />
      <element name="args" implicit="yes" optional="yes" />
         <tempfile property="resource-bundle-list" destdir="${}"
             deleteonexit="true" prefix="resource-bundle-list-" />
         <java jar="${FLEX_HOME}/lib/mxmlc.jar" failonerror="true" fork="true">
            <arg line="-actionscript-file-encoding=UTF-8" />
            <arg line="-local-fonts-snapshot='${FLEX_HOME}/frameworks/localFonts.ser'" />
            <arg line="-load-config='${FLEX_HOME}/frameworks/flex-config.xml'" />
            <arg line="-load-config+='${OUR_SDK_HOME}/resources/flex-config.xml'" />
            <arg line="-external-library-path+='${OUR_SDK_HOME}/libs/our-client-lib.swc'" />
            <arg line="-runtime-shared-library-path=" />
            <arg line="-source-path='${FLEX_HOME}/frameworks'" />
            <arg line="--" />
            <arg line="@{file}" />

    I think I just need to drop down into the mxmlc config for the task to get things compiling, any tips or tricks you might have would be most appreciated.

  7. Support Staff 7 Posted by Yennick Trevels on 29 Aug, 2012 05:53 AM

    Yennick Trevels's Avatar

    Hi Tim,

    Can you show me how the Gradle build already looks like? Then we can start working from there.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac