tag:support.gradlefx.org,2011-05-23:/discussions/questions/18-support-for-i18n-localesGradleFx: Discussion 2016-08-11T02:32:30Ztag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-22T22:49:06Z2012-08-22T22:49:06Zsupport for i18n locales<div><p>Locales are supported. Have a look at the wiki's <a href=
"https://github.com/GradleFx/GradleFx/wiki/Properties-conventions">conventions
page</a>: you'll find the properties <code>localeDir</code> and
<code>locales</code> explained there.</p>
<p>As for an example: you can find one at <a href=
"https://github.com/GradleFx/GradleFx-Examples/blob/master/multiproject-no-conventions/client/build.gradle">
https://github.com/GradleFx/GradleFx-Examples/blob/master/multiproj...</a><br>
This build script explicitly sets both those properties.</p>
<p>Their default values are:</p>
<ul>
<li>localeDir = 'src/main/locale'</li>
<li>locales = []</li>
</ul></div>Maxime Coweztag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-23T14:57:04Z2012-08-23T14:57:05Zsupport for i18n locales<div><p>Awesome! Thanks.</p>
<p>TimG</p></div>tgoeketag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-24T22:09:41Z2012-08-24T22:09:47Zsupport for i18n locales<div><p>Hey GradleFx wizards,</p>
<p>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</p>
<p>locales/fancyApp-en_US.swf<br>
locales/fancyApp-fr_FR.swf</p>
<p>TIA!</p></div>tgoeketag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-25T09:59:26Z2012-08-25T09:59:56Zsupport for i18n locales<div><p>This is a rather special case you have there :)</p>
<p>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.<br>
The flexConvention property is a public property of the Mxmlc task
which contains all the convention properties.</p>
<pre>
<code>def localeNames = ["en_US", "nl_NL"]
localeNames.each { localeName ->
task("compile_${localeName}", type: org.gradlefx.tasks.compile.Mxmlc) {
doFirst {
flexConvention.locales = [localeName]
flexConvention.output = "${project.name}-${localeName}"
}
}
}
task(compileAll)
localeNames.each { localeName ->
compileAll.dependsOn "compile_${localeName}"
}</code>
</pre></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-25T17:30:05Z2012-08-25T17:30:05Zsupport for i18n locales<div><p>Nice approach, Yennick.</p>
<p>Alternatively, you could pass the locale as an argument to your
build script. If your script is something like:</p>
<pre>
<code>locales = [locale]
output = "${project.name}-${locale}"</code>
</pre>
<p>You should be able to build each one of the swf's with the
following command:</p>
<pre>
<code>gradle build -Pen_US
gradle build -Pfr_FR</code>
</pre>
<p>The ´-P´ flag indicates a parameter.<br>
Warning: untested idea!</p></div>Maxime Coweztag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-29T01:40:13Z2012-08-29T01:40:14Zsupport for i18n locales<div><p>Thanks Yennick,</p>
<p>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.</p>
<p>The relevant ANT chunks are:</p>
<pre>
<code> <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}'/bundles.properties" />
<arg line="-output='${WAR_DIR}'/ourmodule.swf"/>
</mxmlc-macro>
<mxmlc-macro>
<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}" />
</mxmlc-macro></code>
</pre>
<p>Which eventually gets added to a war in which I get:</p>
<p>/ourmodule.swf /locales/ourmodule-en_US.swf ... and so on
...</p>
<p>The macro def is as follows:</p>
<pre>
<code> <attribute name="file" default="" />
<element name="args" implicit="yes" optional="yes" />
<sequential>
<tempfile property="resource-bundle-list" destdir="${java.io.tmpdir}"
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'" />
<args/>
<arg line="--" />
<arg line="@{file}" />
</java>
</sequential></code>
</pre>
<p>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.</p></div>Tim Goeketag:support.gradlefx.org,2011-05-23:Comment/182170952012-08-29T05:53:19Z2012-08-29T05:53:19Zsupport for i18n locales<div><p>Hi Tim,</p>
<p>Can you show me how the Gradle build already looks like? Then we
can start working from there.</p></div>Yennick Trevels