|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | | -<project name="Example Project" default="upload-resources" |
| 2 | +<project name="Example Project" |
3 | 3 | xmlns:gp="antlib:com.ibm.g11n.pipeline.ant"> |
4 | 4 |
|
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"/> |
9 | 9 | </taskdef> |
10 | 10 |
|
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"/> |
13 | 13 |
|
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"/> |
17 | 21 | </target> |
18 | 22 |
|
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"/> |
21 | 46 | <targetLanguage lang="fr"/> |
22 | | - <targetLanguage lang="ko"/> |
23 | 47 | <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"/> |
27 | 51 | </bundleSet> |
28 | 52 | </gp:upload> |
29 | 53 | </target> |
30 | 54 |
|
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. |
35 | 60 |
|
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 overwrite="${gp.overwrite}"> |
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"/> |
68 | 84 | <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"/> |
77 | 86 | </bundleSet> |
78 | 87 | </gp:download> |
79 | 88 | </target> |
| 89 | + |
| 90 | + <target name="clean"> |
| 91 | + <delete dir="bin"/> |
| 92 | + <delete dir="dist"/> |
| 93 | + </target> |
80 | 94 | </project> |
0 commit comments