<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../etc/wfrant2html.xsl"?>
<!-- version 2005/07/20 -->
<!-- author Bill Rich, bill@wilandra.com, Wilandra Consulting LLC. Copyright (C) 2004-2005, Wilandra Consulting LLC. All rights reserved. -->
<!-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -->
<!--See http://g11ntoolkit.sourceforge.net/licenseGPL.html for the License Agreement. -->
<!-- =================================================================== -->
<project	name="L10NProcess-macros"
					basedir="."
					default="init"
					xmlns:ac="antlib:net.sf.antcontrib">
	<description>
		Ant macros for an L10N project. This is intended to be imported by the L10NProcess.xml file. There are no targets in this file. This file contains macros that are used by targets in the other L10NProcess files.
	</description>
<!-- =================================================================== -->
	<macrodef	name="getoutputname"
						description="Returns the output file name from the file list item specified. The resulting file name has had the language code resolved.">
		<attribute	name="listitem"/>
		<attribute	name="property"/>
		<sequential>
			<ac:propertyregex	property="ci1.@{listitem}"
											override="true"
											input="@{listitem}"
											regexp=".* /outputname &quot;([^&quot;]*)&quot;.*"
											select="\1"
											casesensitive="true"/>
			<replacelangcode	filenamepattern="${ci1.@{listitem}}"
												property="@{property}"/>
			<property	name="@{property}"
								value="@{listitem}"/>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="getsrcname"
						description="Get the source file name from the specified file list item.">
		<attribute	name="listitem"/>
		<attribute	name="property"/>
		<sequential>
			<ac:propertyregex	property="@{property}"
											override="true"
											input="@{listitem}"
											regexp=".* /inputname &quot;([^&quot;]*)&quot;"
											select="\1"
											casesensitive="true"/>
			<property	name="@{property}"
								value="@{listitem}"/>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="getfiletype"
						description="Get the file type from the specified file list item.">
		<attribute	name="listitem"/>
		<attribute	name="property"/>
		<sequential>
			<ac:propertyregex	property="@{property}"
											override="true"
											input="@{listitem}"
											regexp=".*/type &quot;([^&quot;]*)&quot;"
											select="\1"
											casesensitive="true"/>
			<property	name="@{property}"
								value="@{listitem}"/>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="makefiledir"
						description="Make a dir for a specific file.">
		<attribute	name="filename"/>
		<sequential>
			<dirname file="@{filename}" property="@{filename}.workdir"/>
			<mkdir dir="${@{filename}.workdir}"/>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="n2afile"
						description="Run the native2ascii tool the file.">
		<attribute	name="file"/>
		<attribute	name="ext"/>
		<sequential>
			<copy	file="@{file}"
						tofile="@{file}.UTF8"
						overwrite="true"/>
			<delete	verbose="true">
				<fileset	dir=".">
					<include	name="@{file}"/>
				</fileset>
			</delete>
			<native2ascii	encoding="UTF8"
										dest="."
										includes="@{file}.UTF8">
				<mapper	type="glob"
								from="*.@{ext}.UTF8"
								to="*.@{ext}"/>
			</native2ascii>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="replacelangcode"
						description="Replace the @lang@ code in a file name with the target language code.">
		<attribute	name="filenamepattern"/>
		<attribute	name="property"/>
		<sequential>
			<ac:propertyregex	property="@{property}"
											input="@{filenamepattern}"
											regexp="([^@]*)@lang@([^@]*)"
											replace="\1${TARGETLANG}\2"
											global="true"
											casesensitive="false"/>
			<property	name="@{property}"
								value="@{filenamepattern}"/>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="xlcnfile"
					description="Run the XlClassName tool on the file.">
		<attribute	name="file"/>
		<sequential>
			<java	classname="com.g11ntoolkit.xlclassname.XLClassName"
						fork="true"
						failonerror="true">
				<classpath	refid="project.class.path"/>
				<arg	line="/loc ${TARGETLOCALE}"/>
				<arg	line="/in @{file}"/>
			</java>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
	<macrodef	name="cstfile"
					description="Copy the project source file to its target file.">
		<attribute	name="fileentry"/>
		<sequential>
			<getsrcname	listitem="@{fileentry}"
									property="file.src.@{fileentry}"/>
			<getoutputname	listitem="@{fileentry}"
											property="file.tar.@{fileentry}"/>
			<copy	file="${PRODUCT}/${file.src.@{fileentry}}"
						tofile="${PRODUCT}/${file.tar.@{fileentry}}"
						overwrite="true"/>
		</sequential>
	</macrodef>
<!-- =================================================================== -->
</project>
