Skip to content

Commit

Permalink
Added lang pack build support at the module level
Browse files Browse the repository at this point in the history
  • Loading branch information
sdesai committed Feb 12, 2010
1 parent a85a94f commit 1e6e3fa
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 5 deletions.
18 changes: 17 additions & 1 deletion componentbuild/3.x/module.xml
Expand Up @@ -4,8 +4,9 @@

<import file="${builddir}/shared/targets.xml" description="Targets common to Rollup/Module" />

<target name="build" depends="buildcore, -rollupjs, buildskins" />
<target name="build" depends="buildcore, -rollupjs, buildskins, buildlangs" />
<target name="buildskins" depends="-buildskins, -rollupcss" />
<target name="buildlangs" depends="-buildlangs" />

<!-- CORE -->
<target name="buildcore" depends="builddebug, -createcore, -loggerregex" description="Create component.js">
Expand Down Expand Up @@ -53,6 +54,21 @@
<fixcrlf srcdir="${component.builddir}/assets/skins/sam" includes="${component}.css" eol="${buildfiles.eol}" />
</target>

<target name="-buildlangs" description="Create language packs in the local component build directory" if="component.langs.exist">
<mkdir dir="${component.builddir}/lang" />

<for list="${component.lang}" param="lang" trim="true">
<sequential>
<addlang dir="${component.lang.base}" module="${component}" lang="@{lang}" dest="${component.builddir}/lang" />
<yuicompress src="${component.builddir}/lang/${component}_@{lang}.js" dest="${component.builddir}/lang/${component}_@{lang}-min.js" args="${yuicompressor.js.args.internal}" />
</sequential>
</for>

<addlang dir="${component.lang.base}" module="${component}" lang="" dest="${component.builddir}/lang/" />
<yuicompress src="${component.builddir}/lang/${component}.js" dest="${component.builddir}/lang/${component}-min.js" args="${yuicompressor.js.args.internal}" />

</target>

<target name="-concatskins" if="component.skins.exist">
<concatsource destfile="${component.builddir}/assets/skins/sam/${component}.css" sourcedir="${component.assets.base}" sourcefiles="${component}-core.css, skins/sam/${component}-skin.css" />
<yuicompress src="${component.builddir}/assets/skins/sam/${component}.css" dest="${component.builddir}/assets/skins/sam/${component}.css" args="${yuicompressor.css.args.internal}" />
Expand Down
9 changes: 9 additions & 0 deletions componentbuild/files/langtemplate.txt
@@ -0,0 +1,9 @@
YUI.add('@LANG_MODULE@', function(@YUIVAR@) {

Y.Intl.add(
'@MODULE@',
'@LANG@',
@STRINGS@
);

}, '@VERSION@' @LANG_DETAILS@);
48 changes: 48 additions & 0 deletions componentbuild/shared/macrolib.xml
Expand Up @@ -156,6 +156,54 @@
</sequential>
</macrodef>

<macrodef name="addlang">

<attribute name="dir" />
<attribute name="module" />
<attribute name="dest" />
<attribute name="lang" default="" />
<attribute name="details" default = ""/>

<sequential>
<if>
<equals arg1="@{details}" arg2="" />
<then>
<property name="@{module}@{lang}_details" value="" />
</then>
<else>
<property name="@{module}@{lang}_details" value=",@{details}" />
</else>
</if>

<if>
<equals arg1="@{lang}" arg2="" />
<then>
<property name="@{module}@{lang}_strs" value="@{module}.js" />
</then>
<else>
<property name="@{module}@{lang}_strs" value="@{module}_@{lang}.js" />
</else>
</if>

<loadfile srcfile="@{dir}/${@{module}@{lang}_strs}" property="@{module}@{lang}-strs-loaded" />

<echo level="info">Wrapping @{dir}/${@{module}@{lang}_strs} in YUI.add, Y.Intl.add</echo>

<copy file="${builddir}/files/langtemplate.txt" tofile="@{dest}/${@{module}@{lang}_strs}" overwrite="true">
<filterset>
<!-- TODO - Integration -->
<filter token="LANG" value="@{lang}" />
<filter token="LANG_MODULE" value="@{module};lang:@{lang}" />
<filter token="STRINGS" value="${@{module}@{lang}-strs-loaded}" />
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}" />
<filter token="LANG_DETAILS" value="${@{module}@{lang}_details}" />
</filterset>
</copy>
</sequential>

</macrodef>

<macrodef name="addmodule">
<attribute name="file" />
<attribute name="module" />
Expand Down
14 changes: 10 additions & 4 deletions componentbuild/shared/properties.xml
Expand Up @@ -54,17 +54,19 @@
<!-- Component Properties -->
<property name="component.module" value="${component}" />
<property name="component.basedir" location="${buildfile.dir}" />
<property name="component.jsfiles.base" value="${component.basedir}/js" />
<property name="component.jsfiles.base" location="${component.basedir}/js" />

<property name="component.lang.base" location="${component.basedir}/lang" />

<property name="component.assets.flatten" value="true" />
<property name="component.assets.base" value="${component.basedir}/assets" />
<property name="component.assets.base" location="${component.basedir}/assets" />
<property name="component.assets.files" value="**/*" />

<property name="component.assets.legacy.flatten" value="true" />
<property name="component.assets.legacy.base" value="${component.assets.base}/legacy" />
<property name="component.assets.legacy.base" location="${component.assets.base}/legacy" />
<property name="component.assets.legacy.files" value="**/*" />

<property name="component.assets.skins.base" value="${component.assets.base}/skins" />
<property name="component.assets.skins.base" location="${component.assets.base}/skins" />
<property name="component.assets.skins.files" value="**/*" />

<condition property="component.skins.exist">
Expand All @@ -84,6 +86,10 @@

<available file="${component.assets.base}" type="dir" property="component.assets.exist"/>

<condition property="component.langs.exist">
<isset property="component.lang" />
</condition>

<!--
DEPRECATED: component.basefilename and component.releasetype are deprecated
We used to mark filenames with suffixes (-beta, -experimental), which we no longer do
Expand Down
6 changes: 6 additions & 0 deletions componentbuild/shared/targets.xml
Expand Up @@ -80,6 +80,12 @@
</copy>
</target>

<target name="deploylang" description="Copy language bundles to global build location" if="component.langs.exist">
<copy todir="${global.build.component.assets}/lang" preservelastmodified="true">
<fileset dir="${component.builddir}/lang" includes="*.js" />
</copy>
</target>

<target name="deploydocs" description="Copy doc files to global doc locations">
<!-- TODO -->
</target>
Expand Down

0 comments on commit 1e6e3fa

Please sign in to comment.