Permalink
Browse files

Rollup lang support fixed - now adds rollup YUI.add correctly

  • Loading branch information...
1 parent d24c924 commit 937cc5955400cd5e8cd306e6bfc3f66a88965d84 @sdesai sdesai committed Feb 17, 2010
@@ -61,12 +61,10 @@
<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>
@@ -76,17 +74,11 @@
<concat destfile="${rollup.builddir}/lang/${rollup.component}_@{lang}.js" append="true" fixlastline="true">
<fileset dir="${component.builddir}/lang" includes="*_@{lang}.js" />
</concat>
- <concat destfile="${rollup.builddir}/lang/${rollup.component}_@{lang}-min.js" append="true" fixlastline="true">
- <fileset dir="${component.builddir}/lang" includes="*_@{lang}-min.js" />
- </concat>
</sequential>
</for>
<concat destfile="${rollup.builddir}/lang/${rollup.component}.js" append="true" fixlastline="true">
<filelist dir="${component.builddir}/lang" files="${component}.js" />
</concat>
- <concat destfile="${rollup.builddir}/lang/${rollup.component}-min.js" append="true" fixlastline="true">
- <filelist dir="${component.builddir}/lang" files="${component}-min.js" />
- </concat>
</target>
<target name="-concatskins" if="component.skins.exist">
@@ -31,25 +31,16 @@
</target>
<target name="-rolluplangs" if="rolluplangs">
- <echo>${component}</echo>
- <echo>${component.lang}</echo>
- <echo>${component.langs.exist}</echo>
- <for list="${component.lang}" param="lang" trim="true">
+ <for list="${component.rollup.lang}" param="lang" trim="true">
<sequential>
<concat destfile="${rollup.builddir}/lang/${rollup.component}_@{lang}.js" append="true" fixlastline="true">
<fileset dir="${component.builddir}/lang" includes="*_@{lang}.js" />
</concat>
- <concat destfile="${rollup.builddir}/lang/${rollup.component}_@{lang}-min.js" append="true" fixlastline="true">
- <fileset dir="${component.builddir}/lang" includes="*_@{lang}-min.js" />
- </concat>
</sequential>
</for>
<concat destfile="${rollup.builddir}/lang/${rollup.component}.js" append="true" fixlastline="true">
<filelist dir="${component.builddir}/lang" files="${component}.js" />
</concat>
- <concat destfile="${rollup.builddir}/lang/${rollup.component}-min.js" append="true" fixlastline="true">
- <filelist dir="${component.builddir}/lang" files="${component}-min.js" />
- </concat>
</target>
<target name="-prependall" depends="-prependdebug, -prepend" if="component.prependfiles" />
@@ -58,5 +49,12 @@
<target name="-registerall" unless="register.skip">
<addrollup module="${component.module}" file="${component.builddir}/${component.basefilename}-debug.js" details="${component.details.hash}" />
<addrollup module="${component.module}" file="${component.builddir}/${component.basefilename}.js" details="${component.details.hash}" />
+
+ <if>
+ <available file="${component.builddir}/lang/" type="dir" />
+ <then>
+ <addlangrollup module="${component.module}" dir="${component.builddir}/lang/" />
+ </then>
+ </if>
</target>
</project>
@@ -178,22 +178,21 @@
<if>
<equals arg1="@{lang}" arg2="" />
<then>
- <property name="@{module}@{lang}_strs" value="@{module}.js" />
+ <property name="@{module}@{lang}_fullname" value="@{module}" />
</then>
<else>
- <property name="@{module}@{lang}_strs" value="@{module}_@{lang}.js" />
+ <property name="@{module}@{lang}_fullname" value="@{module}_@{lang}" />
</else>
</if>
- <loadfile srcfile="@{dir}/${@{module}@{lang}_strs}" property="@{module}@{lang}-strs-loaded" />
+ <loadfile srcfile="@{dir}/${@{module}@{lang}_fullname}.js" 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">
+ <copy file="${builddir}/files/langtemplate.txt" tofile="@{dest}/${@{module}@{lang}_fullname}.js" overwrite="true">
<filterset>
- <!-- TODO - Integration -->
<filter token="LANG" value="@{lang}" />
- <filter token="LANG_MODULE" value="@{module};lang:@{lang}" />
+ <filter token="LANG_MODULE" value="lang/${@{module}@{lang}_fullname}" />
<filter token="STRINGS" value="${@{module}@{lang}-strs-loaded}" />
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}" />
@@ -260,4 +259,71 @@
</sequential>
</macrodef>
+ <macrodef name="addlangrollup">
+
+ <attribute name="module" />
+ <attribute name="dir" />
+
+ <sequential>
+ <echo level="info">Registering rollup info for lang files in @{dir} using YUI.add</echo>
+
+ <for list="${component.rollup.lang}" param="lang" trim="true">
+ <sequential>
+ <loadfile srcfile="@{dir}/@{module}_@{lang}.js" property="@{module}-@{lang}-code" />
+
+ <var name="lang.use" value="{use:[" />
+
+ <for list="${component.lang.use}" param="submod" trim="true">
+ <sequential>
+ <var name="lang.use" value="${lang.use}'lang/@{submod}_@{lang}'," />
+ </sequential>
+ </for>
+
+ <var name="lang.use" value="${lang.use}]}" />
+
+ <propertyregex property="@{module}-@{lang}-details"
+ input="${lang.use}"
+ regexp="(\,\s*?\])"
+ replace="]"
+ casesensitive="false" />
+
+ <copy file="${builddir}/files/rolluptemplate.txt" tofile="@{dir}/@{module}_@{lang}.js" overwrite="true">
+ <filterset>
+ <filter token="CODE" value="${@{module}-@{lang}-code}"/>
+ <filter token="YUIVAR" value="${yui.variable}" />
+ <filter token="MODULE" value="lang/@{module}_@{lang}"/>
+ <filter token="DETAILS" value=", ${@{module}-@{lang}-details}"/>
+ </filterset>
+ </copy>
+ </sequential>
+ </for>
+
+ <loadfile srcfile="@{dir}/@{module}.js" property="@{module}--code" />
+
+ <var name="lang.use" value="{use:[" />
+ <for list="${component.lang.use}" param="submod" trim="true">
+ <sequential>
+ <var name="lang.use" value="${lang.use}'lang/@{submod}'," />
+ </sequential>
+ </for>
+ <var name="lang.use" value="${lang.use}]}" />
+
+ <propertyregex property="@{module}--details"
+ input="${lang.use}"
+ regexp="(\,\s*?\])"
+ replace="]"
+ casesensitive="false" />
+
+ <copy file="${builddir}/files/rolluptemplate.txt" tofile="@{dir}/@{module}.js" overwrite="true">
+ <filterset>
+ <filter token="CODE" value="${@{module}--code}"/>
+ <filter token="YUIVAR" value="${yui.variable}" />
+ <filter token="MODULE" value="lang/@{module}"/>
+ <filter token="DETAILS" value=", ${@{module}--details}"/>
+ </filterset>
+ </copy>
+
+ </sequential>
+ </macrodef>
+
</project>
@@ -88,8 +88,10 @@
<condition property="component.langs.exist">
<and>
- <isset property="component.lang" />
- <available file="${component.lang.base}" type="dir" />
+ <or>
+ <isset property="component.lang" />
+ <isset property="component.rollup.lang" />
+ </or>
</and>
</condition>
@@ -41,6 +41,20 @@
<!-- MIN -->
<target name="minify" description="Create component-min.js from component.js">
<yuicompress src="${component.builddir}/${component.basefilename}.js" dest="${component.builddir}/${component.basefilename}-min.js" args="${yuicompressor.js.args.internal}" />
+ <if>
+ <available file="${component.builddir}/lang" type="dir" />
+ <then>
+ <for param="file">
+ <path>
+ <fileset dir="${component.builddir}/lang" includes="*.js"/>
+ </path>
+ <sequential>
+ <basename file="@{file}" property="@{file}" suffix=".js" />
+ <yuicompress src="@{file}" dest="${component.builddir}/lang/${@{file}}-min.js" args="${yuicompressor.js.args.internal}" />
+ </sequential>
+ </for>
+ </then>
+ </if>
</target>
<target name="lint" description="Run jslint over the local build files (default settings)" unless="lint.skip">

0 comments on commit 937cc59

Please sign in to comment.