Commit c3541fcc authored by Guus der Kinderen's avatar Guus der Kinderen

OF-947: Overlay should be able to modify i18n

i18n files can now be modified by files in <overlay>/i18n/. Files are merged,
where the overlay values have preference over the original values.

This commit removes support for the (poorly implemented) overlay.properties file.
parent 0566166e
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
<property name="overlay.web.dir" value="${overlay.dir}/webapp"/> <property name="overlay.web.dir" value="${overlay.dir}/webapp"/>
<property name="overlay.lib.dir" value="${overlay.dir}/lib"/> <property name="overlay.lib.dir" value="${overlay.dir}/lib"/>
<property name="overlay.conf.dir" value="${overlay.dir}/conf"/> <property name="overlay.conf.dir" value="${overlay.dir}/conf"/>
<property name="overlay.properties.file" value="overlay.properties"/> <property name="overlay.i18n.dir" value="${overlay.dir}/i18n"/>
<property name="overlay.compile.dir" value="${work.dir}/overlay/classes"/> <property name="overlay.compile.dir" value="${work.dir}/overlay/classes"/>
<property name="javadoc.src.dir" value="${src.dir}/javadoc"/> <property name="javadoc.src.dir" value="${src.dir}/javadoc"/>
...@@ -137,6 +137,9 @@ ...@@ -137,6 +137,9 @@
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"> <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
<classpath refid="ant.dependencies" /> <classpath refid="ant.dependencies" />
</taskdef> </taskdef>
<taskdef name="propertymerge" classname="org.jugbb.ant.propertymerge.PropertyMergeTask">
<classpath refid="ant.dependencies" />
</taskdef>
<typedef name="srcinc" classname="com.jivesoftware.tools.selector.IncludeSourceSelector" > <typedef name="srcinc" classname="com.jivesoftware.tools.selector.IncludeSourceSelector" >
<classpath refid="ant.dependencies" /> <classpath refid="ant.dependencies" />
</typedef> </typedef>
...@@ -150,7 +153,7 @@ ...@@ -150,7 +153,7 @@
<available type="dir" file="${overlay.web.dir}" property="overlay.web.dir.found"/> <available type="dir" file="${overlay.web.dir}" property="overlay.web.dir.found"/>
<available type="dir" file="${overlay.lib.dir}" property="overlay.lib.dir.found"/> <available type="dir" file="${overlay.lib.dir}" property="overlay.lib.dir.found"/>
<available type="dir" file="${overlay.conf.dir}" property="overlay.conf.dir.found"/> <available type="dir" file="${overlay.conf.dir}" property="overlay.conf.dir.found"/>
<available type="file" file="${overlay.properties.file}" property="overlay.properties.file.found"/> <available type="dir" file="${overlay.i18n.dir}" property="overlay.i18n.dir.found"/>
<!-- When overlay is used the content of "lib.merge.dir" needs to be combined with the content of "overlay.lib.dir" <!-- When overlay is used the content of "lib.merge.dir" needs to be combined with the content of "overlay.lib.dir"
Here, "libs.to.merge" is created which will always refer to the correct combination. "libs.to.merge" should be Here, "libs.to.merge" is created which will always refer to the correct combination. "libs.to.merge" should be
...@@ -326,21 +329,50 @@ ...@@ -326,21 +329,50 @@
<!-- i18n ================================================================================== --> <!-- i18n ================================================================================== -->
<!-- Note, this is a "private" target - no need to call it externally --> <!-- Note, this is a "private" target - no need to call it externally -->
<target name="-i18n"> <target name="-i18n">
<!-- Auto generates a default base i18n file -->
<mkdir dir="${target.i18n.dir}"/> <mkdir dir="${target.i18n.dir}"/>
<copy file="${src.i18n.dir}/${i18n.basename}_${i18n.default.locale}.properties"
<if>
<equals arg1="${overlay.i18n.dir.found}" arg2="true"/>
<then>
<!-- Overlay files exist for i18n: append/override the files that ship with Openfire. -->
<foreach target="-i18n-overlay" param="i18n-propertyfile">
<path>
<fileset dir="${src.i18n.dir}">
<include name="${i18n.basename}*.properties"/>
</fileset>
</path>
</foreach>
</then>
<else>
<!-- No overlay for i18n: simply copy all files. -->
<copy todir="${target.i18n.dir}">
<fileset dir="${src.i18n.dir}" includes="*.properties"/>
</copy>
</else>
</if>
<!-- Auto generates a default base i18n file -->
<copy file="${target.i18n.dir}/${i18n.basename}_${i18n.default.locale}.properties"
tofile="${target.i18n.dir}/${i18n.basename}.properties"/> tofile="${target.i18n.dir}/${i18n.basename}.properties"/>
<!-- if title override file exists, overwrite all i18n files --> </target>
<!-- Note, this is a "private" target - no need to call it externally -->
<target name="-i18n-overlay">
<basename property="filename" file="${i18n-propertyfile}"/>
<if> <if>
<equals arg1="${overlay.properties.file.found}" arg2="true"/> <available file="${overlay.i18n.dir}/${filename}"/>
<then> <then>
<property file="${overlay.properties.file}"/> <propertymerge
<replace dir="${target.i18n.dir}"> inputpropertyfile="${src.i18n.dir}/${filename}"
<replacefilter token="title = Wildfire" value="title=${title}"/> mergepropertyfile="${overlay.i18n.dir}/${filename}"
<replacefilter token="short.title = Wildfire" value="short.title=${short.title}"/> outputpropertyfile="${target.i18n.dir}/${filename}"
</replace> ignoreMissingMergeFile="true" />
</then> </then>
<else>
<copy file="${src.i18n.dir}/${filename}" tofile="${target.i18n.dir}/${filename}"/>
</else>
</if> </if>
</target> </target>
...@@ -387,7 +419,6 @@ ...@@ -387,7 +419,6 @@
<!-- Make main Openfire jar --> <!-- Make main Openfire jar -->
<jar jarfile="${jar.dest.dir}/${jar.name}" index="true" duplicate="preserve"> <jar jarfile="${jar.dest.dir}/${jar.name}" index="true" duplicate="preserve">
<fileset dir="${compile.dir}" includes="**/*.class" excludes="org/jivesoftware/openfire/starter/ServerStarter*.class,org/jivesoftware/openfire/launcher/*.class"/> <fileset dir="${compile.dir}" includes="**/*.class" excludes="org/jivesoftware/openfire/starter/ServerStarter*.class,org/jivesoftware/openfire/launcher/*.class"/>
<fileset dir="${src.i18n.dir}" includes="*.properties"/>
<fileset dir="${target.i18n.dir}" includes="*.properties"/> <fileset dir="${target.i18n.dir}" includes="*.properties"/>
<fileset dir="${resources.dir}/jar" includes="**"/> <fileset dir="${resources.dir}/jar" includes="**"/>
<archives> <archives>
...@@ -886,7 +917,6 @@ ...@@ -886,7 +917,6 @@
<!-- Copy the i18n files to the resources dir. This way they won't be in the jar only --> <!-- Copy the i18n files to the resources dir. This way they won't be in the jar only -->
<copy todir="${release.src.out.dir}/resources/i18n"> <copy todir="${release.src.out.dir}/resources/i18n">
<fileset dir="${target.i18n.dir}" includes="*.properties"/> <fileset dir="${target.i18n.dir}" includes="*.properties"/>
<fileset dir="${src.i18n.dir}" includes="*.properties"/>
</copy> </copy>
<!-- Copy build --> <!-- Copy build -->
<copy todir="${release.src.out.dir}/build"> <copy todir="${release.src.out.dir}/build">
...@@ -972,7 +1002,6 @@ ...@@ -972,7 +1002,6 @@
<!-- Copy the i18n files to the resources dir. This way they won't be in the jar only --> <!-- Copy the i18n files to the resources dir. This way they won't be in the jar only -->
<copy todir="${release.out.dir}/resources/i18n"> <copy todir="${release.out.dir}/resources/i18n">
<fileset dir="${target.i18n.dir}" includes="*.properties"/> <fileset dir="${target.i18n.dir}" includes="*.properties"/>
<fileset dir="${src.i18n.dir}" includes="*.properties"/>
</copy> </copy>
<!-- Package the release --> <!-- Package the release -->
......
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
<h2><a name="mysql">File Structure</a></h2> <h2><a name="mysql">File Structure</a></h2>
<p>To cusomize files, create the following file structure in your <tt>openfireHome</tt> <p>To customize files, create the following file structure in your <tt>openfireHome</tt>
directory (where all the source files are on your filesystem). directory (where all the source files are on your filesystem).
</p> </p>
<pre>custom/ <pre>custom/
| - overlay.properties &lt;- Properties file to replace text in i18n files (optional) | - i18n/ &lt;- Directory to place translation files to be overridden
| - conf/ &lt;- Directory to place configuration files to be overridden | - conf/ &lt;- Directory to place configuration files to be overridden
| - lib/ &lt;- Directory to place any private or 3rd prty jar files | - lib/ &lt;- Directory to place any private or 3rd prty jar files
| - source/ &lt;- Directory to place java source files to be overridden | - source/ &lt;- Directory to place java source files to be overridden
...@@ -74,24 +74,13 @@ ...@@ -74,24 +74,13 @@
functionality to bundle these changes in a separate jar file. functionality to bundle these changes in a separate jar file.
</p> </p>
<h2>Overlay Properties File</h2>
<p>The i18n files have been modified to be as generic as possible (not to mention this project
by name). In cases where that could not be avioded, two keys are responsible. We have
made it possible to modify these keys by means of an optional properties file, <tt>overlay.properties</tt>
which you place in your <tt>custom/</tt> folder. If you want to override these
default properties just create this file. The build will continue to work if you haven't
created the file.
</p>
<p> <p>
The overlay.properties file will currently replace the following keys in the i18n files. The texts that are used in the administration panel (as well as some other texts) are taken from various
Note: this properties file should follow the java.util.Properties text file format. translation files under the <tt>src/i18n</tt> directory. To customize such a file, a file by the same name
can be added in the <tt>custom/i18n</tt> directory. The build process will merge both files, which you to
add your own properties, as well as override existing properties, without the need to copy all properties
that aren't of interest to you.
</p> </p>
<ul>
<li><em>title</em> - Title key (usually in the title bar of an HTML page)</li>
<li><em>short.title</em> - Short title, also used frequently</li>
</ul>
<h2>Build</h2> <h2>Build</h2>
<p>Simply build the application as normal. You may need to run the ant <tt>clean</tt> <p>Simply build the application as normal. You may need to run the ant <tt>clean</tt>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment