Skip to content

Commit 4d855ad

Browse files
author
Yoshito Umaoka
committed
Updated example and user guide
Cleaned up example. Provided simple instruction for the example. Updated user guide and clarify the important points. We probably need full task/attribute reference.
1 parent 76412ed commit 4d855ad

11 files changed

Lines changed: 204 additions & 294 deletions

File tree

gp-ant-task/example/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Globalization Pipeline Ant Task Example
2+
3+
This directory contains example Ant build.xml illustrating how
4+
Globalization Pipeline Ant Task works.
5+
6+
Please follow the steps below to set up the environment.
7+
8+
1. Configure Appache Ant 1.9 or later version.
9+
2. Download **gp-ant-task-X.X.X-with-dependencies.jar** from GitHub
10+
[gp-java-tools release page](https://github.com/IBM-Bluemix/gp-java-tools/releases).
11+
Copy the downloaded jar file to this (example) directory and rename jar file to
12+
**gp-ant-task.jar**.
13+
3. Edit **creds.json** in this directory and put actual Globalization Pipeline
14+
service credentials.
15+
16+
There are 4 example targets (and `clean`) defined in the example build.xml.
17+
You can try `> ant upload-props` to upload the contents of Java property files in the
18+
specified directory to your Globalization Pipeline instance.
19+
Then try `> ant download-props` to see how translated property files are downloaded.

gp-ant-task/example/build.xml

Lines changed: 74 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,94 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<project name="Example Project" default="upload-resources"
2+
<project name="Example Project"
33
xmlns:gp="antlib:com.ibm.g11n.pipeline.ant">
44

5-
<taskdef uri="antlib:com.ibm.g11n.pipeline.ant" resource="com/ibm/g11n/pipeline/ant/antlib.xml">
6-
<!-- If the gp-ant-task jar is not added to ANT_HOME/lib folder,
7-
then you may include the classpath for the jar like shown below-->
8-
<classpath path="gp-ant-task.jar"/>
5+
<taskdef uri="antlib:com.ibm.g11n.pipeline.ant"
6+
resource="com/ibm/g11n/pipeline/ant/antlib.xml">
7+
<!-- Specify the actual path to the Globalization Pipeline Ant Task jar -->
8+
<classpath path="gp-ant-task.jar"/>
99
</taskdef>
1010

11-
<!--Specify the location of the credentials json file-->
12-
<property name="gp.credentials" value="credentials.json"/>
11+
<!-- Specify the location of the credentials json file -->
12+
<property name="gp.credentials.json" value="creds.json"/>
1313

14-
<!-- basic usecase for uploading resources(this uploads java .properties files by default)-->
15-
<target name="upload-resources">
16-
<gp:upload credentialsJson= "${gp.credentials}" sourceDir="resources"/>
14+
<!--
15+
Basic use case - uploading translation source resources.
16+
This target uploads the contents of java property files without
17+
language suffix under 'src' directory.
18+
-->
19+
<target name="upload-props">
20+
<gp:upload credentialsJson= "${gp.credentials.json}" sourceDir="src"/>
1721
</target>
1822

19-
<target name="upload-resources-adv">
20-
<gp:upload credentialsJson= "${gp.credentials}" sourceDir="resources">
23+
<!--
24+
Basic use case for downloading translated resources.
25+
This target downloads translated java property files corresponding
26+
to translation source files available under 'src' directory.
27+
The output files are created under 'bin' directory with
28+
language suffix in property file names.
29+
-->
30+
<target name="download-props">
31+
<gp:download credentialsJson="${gp.credentials.json}" sourceDir="src" outputDir="bin"/>
32+
</target>
33+
34+
<!--
35+
Advanced upload use case example.
36+
This target uploads the contents of source JSON files in
37+
'en' directory under 'web' directory.
38+
If the corresponding bundle in Globalization Pipeline service instance
39+
is not available, this target creates a new one and set Spanish(es),
40+
French(fr), Brazilian Portuguese(pt-BR) and Simplified Chinese(zh-Hans)
41+
as translation target languages.
42+
-->
43+
<target name="upload-json">
44+
<gp:upload credentialsJson= "${gp.credentials.json}">
45+
<targetLanguage lang="es"/>
2146
<targetLanguage lang="fr"/>
22-
<targetLanguage lang="ko"/>
2347
<targetLanguage lang="pt-BR"/>
24-
<targetLanguage lang="es"/>
25-
<bundleSet type="JSON">
26-
<fileset dir="resources" includes="**/*.json"/>
48+
<targetLanguage lang="zh-Hans"/>
49+
<bundleSet type="JSON">
50+
<fileset dir="web" includes="**/en/*.json"/>
2751
</bundleSet>
2852
</gp:upload>
2953
</target>
3054

31-
<!-- basic use case for downloading resources (this downloads the java .properties files to the target/classes folder of the project) -->
32-
<target name="download-translations">
33-
<gp:download credentialsJson="${gp.credentials}" sourceDir="resources" outputDir="target"/>
34-
</target>
55+
<!--
56+
Advanced download use case example.
57+
This target downloads translated JSON files corresponding to
58+
translation source files available in 'en' directory under
59+
'web' directory.
3560
36-
<!-- advanced use case for downloading resources. This downloads java properties files and json properties files and organizes them differently -->
37-
<target name="download-translations-adv">
38-
<property name="gp.url" value="https://gp-rest.ng.bluemix.net/translate/rest"/>
39-
<property name="gp.userId" value="b9818b62e1db014dedb2bbb8eaf176b4"/>
40-
<property name="gp.password" value="Tl7edjvzdwd2Rqjpztdbitagfendv6i4"/>
41-
<property name="gp.instanceId" value="1b088966b5fed337baf9940496db40ac"/>
42-
<property name="gp.download.src" value="resources"/>
43-
<property name="gp.download.dest" value="target"/>
44-
<property name="gp.overwrite" value="true"/>
45-
<property name="gp.languageIdStyle" value="BCP47_UNDERSCORE"/>
46-
<property name="gp.outputDir" value="target"/>
47-
<property name="gp.type" value="JSON"/>
48-
<property name="gp.sourceLanguage" value="en"/>
49-
<property name="gp.outputContentOption" value="MERGE_TO_SOURCE"/>
50-
<property name="gp.bundleLayout" value="LANGUAGE_DIR"/>
51-
<property name="gp.includepattern" value="**/*.json"/>
52-
<property name="gp.excludepattern" value="**/*_*.json"/>
53-
<gp:download>
54-
<credentials url="${gp.url}" userId="${gp.userId}" password="${gp.password}" instanceId="${gp.instanceId}"/>
55-
<targetLanguage lang="es"/>
56-
<targetLanguage lang="pt-BR"/>
57-
<bundleSet
58-
type="${gp.type}"
59-
sourceLanguage="${gp.sourceLanguage}"
60-
languageIdStyle="${gp.languageIdStyle}"
61-
outputContentOption="${gp.outputContentOption}"
62-
bundleLayout="${gp.bundleLayout}"
63-
outputDir="${gp.download.dest}">
64-
<targetLanguage lang="ja"/>
65-
<targetLanguage lang="fr"/>
66-
<targetLanguage lang="ko"/>
67-
<targetLanguage lang="pt-BR"/>
61+
The output files are created under language directory (LANGUAGE_DIR)
62+
at the same level with 'en' under 'dist/web' directory.
63+
64+
The languge code for Brazilian Portugues(pt-BR) will be changed
65+
to 'pt', the language code for Simplified Chinese(zh-Hans) is
66+
changed to 'zh-CN'. Language code separator (<languageMap> elements).
67+
68+
The output language directory name will use '-' as the subtag
69+
separator (languageIdStyle="BPC47").
70+
71+
When the source file path is web/nls/en/colors.json, the output files are:
72+
- dist/web/nls/es/colors.json
73+
- dist/web/nls/fr/colors.json
74+
- dist/web/nls/pt/colors.json
75+
- dist/web/nls/zh-CN/colors.json
76+
-->
77+
<target name="download-json">
78+
<gp:download credentialsJson="${gp.credentials.json}">
79+
<bundleSet type="JSON"
80+
languageIdStyle="BCP47"
81+
bundleLayout="LANGUAGE_DIR"
82+
outputDir="dist/web">
83+
<fileset dir="web" includes="**/en/*.json"/>
6884
<languageMap from="pt-BR" to="pt"/>
69-
<fileset dir="${gp.download.src}" includes="${gp.includepattern}" excludes="${gp.excludepattern}"/>
70-
</bundleSet>
71-
<bundleSet
72-
type="JAVA"
73-
sourceLanguage="en"
74-
languageIdStyle="BCP47"
75-
outputDir="${gp.download.dest}">
76-
<fileset dir="${gp.download.src}" includes="**/*.properties"/>
85+
<languageMap from="zh-Hans" to="zh-CN"/>
7786
</bundleSet>
7887
</gp:download>
7988
</target>
89+
90+
<target name="clean">
91+
<delete dir="bin"/>
92+
<delete dir="dist"/>
93+
</target>
8094
</project>

gp-ant-task/example/credentials.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

gp-ant-task/example/creds.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"url": "<Globalization Pipeline service URL>",
3+
"userId": "<User ID>",
4+
"password": "<Password>",
5+
"instanceId": "<Globalization Pipeline service instance ID>"
6+
}
52 Bytes
Binary file not shown.

gp-ant-task/example/resources/com/test.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

gp-ant-task/example/resources/com/test.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# UI menu strings
3+
#
4+
5+
file.new = New
6+
file.open = Open
7+
file.save = Save
8+
9+
edit.cut = Cut
10+
edit.copy = Copy
11+
edit.paste = Paste
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Message text and patterns processed by MessageFormat
3+
#
4+
5+
# {0} is a file name.
6+
err.not.found = Specified file {0} is not found.
7+
err.permission = You are not authorized to browse the contents.
8+
9+
# {0} is a use name.
10+
warn.in.use = The file is currently used by {0}.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"color-green": "green",
3+
"color-yellow":"yellow",
4+
"color-red":"red"
5+
}

0 commit comments

Comments
 (0)