|
| 1 | +# Globalization Pipeline CLI Tool User Guide |
| 2 | +<!-- |
| 3 | +/* |
| 4 | + * Copyright IBM Corp. 2016 |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | +--> |
| 19 | + |
| 20 | +* [Overview](#TOC-Overview) |
| 21 | +* [Prerequisites](#TOC-Prerequisites) |
| 22 | +* [Command Reference](#TOC-Command-Reference) |
| 23 | + * [Help Command](#TOC-Cmd-Help) |
| 24 | + * [Bundle Commands](#TOC-Cmd-Bundle) |
| 25 | + * [User Commands](#TOC-Cmd-User) |
| 26 | + * [Other Commands](#TOC-Cmd-Others) |
| 27 | +* [How-To](#TOC-How-To) |
| 28 | + * [Import Existing Translations](#TOC-Import-Existing-Translations) |
| 29 | + |
| 30 | +--- |
| 31 | +## <a name="TOC-Overview"></a>Overview |
| 32 | + |
| 33 | +Globalization Pipeline CLI (Command Line Interface) Tool is designed for |
| 34 | +manipulating translation bundles hosted by Globalization Pipeline service |
| 35 | +on command line. |
| 36 | + |
| 37 | +--- |
| 38 | +## <a name="TOC-Prerequisites"></a>Prerequisites |
| 39 | + |
| 40 | +Globalization Pipeline CLI Tool is distributed in a single jar package. |
| 41 | +You need Java SE Runtime Environment 7 or later version to run the tool. |
| 42 | + |
| 43 | +--- |
| 44 | +## <a name="TOC-Command-Reference"></a>Command Reference |
| 45 | + |
| 46 | +Most of commands takes user credentials for a Globalization Pipeline service |
| 47 | +instance. The common command options for specifying user credentials are |
| 48 | +below. |
| 49 | + |
| 50 | +* -s (--serviceUrl): Globalization Pipeline service URL |
| 51 | +* -i (--instanceId): Service instance ID |
| 52 | +* -u (--user): User ID |
| 53 | +* -p (--password): Password |
| 54 | + |
| 55 | +For example, |
| 56 | +``` |
| 57 | +java -jar gp-cli.jar list-bundle -s https://gp-rest.ng.bluemix.net/translate/rest -i 1d42b9329d6f5ab173c82810c819afa6 -u 8492e8d7bc28d9dc34a31a6d0ec7384e -p DoRfuq1w1ohx8vKXoZHHMenxxpSyoF0u |
| 58 | +``` |
| 59 | +You can access these credentials on Bluemix Dashboard. For more details, |
| 60 | +plese see [Credentials](https://github.com/IBM-Bluemix/gp-common/blob/master/README.md#4-credentials) |
| 61 | +section in the Globalization Pipeline Quick Start Guide. |
| 62 | + |
| 63 | +Alternatively, you can store the credentials in a JSON file and use -j (--jsonCreds) |
| 64 | +option to specify the file. For example, you can create a JSON file `mycreds.json' |
| 65 | +with the contents below (Note: actual property values should match the actual service |
| 66 | +instance's credentials): |
| 67 | +``` |
| 68 | +{ |
| 69 | + "url": "https://gp-rest.ng.bluemix.net/translate/rest", |
| 70 | + "userId": "8492e8d7bc28d9dc34a31a6d0ec7384e", |
| 71 | + "password": "DoRfuq1w1ohx8vKXoZHHMenxxpSyoF0u", |
| 72 | + "instanceId": "1d42b9329d6f5ab173c82810c819afa6" |
| 73 | +} |
| 74 | +``` |
| 75 | +With -j option, following command is equivalent to the above example. |
| 76 | +``` |
| 77 | +java -jar gp-cli.jar list-bundle -j mycreds.json |
| 78 | +``` |
| 79 | +--- |
| 80 | +### <a name="TOC-Cmd-Help"></a>Help Command |
| 81 | + |
| 82 | +The help command prints out all commands and available options. |
| 83 | +``` |
| 84 | +java -jar gp-cli.jar help |
| 85 | +``` |
| 86 | +--- |
| 87 | +### <a name="TOC-Cmd-Bundle"></a>Bundle Commands |
| 88 | + |
| 89 | +#### list (list-bundle) |
| 90 | + |
| 91 | +Prints out a list of bundle IDs available in the service instance. |
| 92 | +``` |
| 93 | +java -jar gp-cli.jar list -j mycreds.json |
| 94 | +``` |
| 95 | +Below is an example output |
| 96 | +``` |
| 97 | +["MyBundle1", "MyBundle2"] |
| 98 | +``` |
| 99 | + |
| 100 | +#### show (show-bundle) |
| 101 | + |
| 102 | +Prints out a bundle's summary information. The following example shows |
| 103 | +the information of bundle *MyBundle1*. |
| 104 | +``` |
| 105 | +java -jar gp-cli.jar show -b MyBundle1 -j mycreds.json |
| 106 | +``` |
| 107 | +Below is an example output. |
| 108 | +``` |
| 109 | +{ |
| 110 | + "sourceLanguage": "en", |
| 111 | + "targetLanguages": [ |
| 112 | + "de", |
| 113 | + "es", |
| 114 | + "fr", |
| 115 | + "it", |
| 116 | + "ja", |
| 117 | + "ko", |
| 118 | + "pt-BR", |
| 119 | + "zh-Hans", |
| 120 | + "zh-Hant" |
| 121 | + ], |
| 122 | + "readOnly": false, |
| 123 | + "updatedBy": "(dash+3f4bb9f12d6f5db965482811c81ca215)mike@acme.com", |
| 124 | + "updatedAt": "2016-07-07T12:02:34.788-04" |
| 125 | +} |
| 126 | +``` |
| 127 | + |
| 128 | +#### create (create-bundle) |
| 129 | + |
| 130 | +Creates a new bundle. This command creates an empty bundle with |
| 131 | +specified bundle ID and languages. |
| 132 | + |
| 133 | +The following example creates |
| 134 | +a new bundle with ID *MyNewBundle* with English(en) as source language, |
| 135 | +and French(fr) and German(de) as target languages. The first language |
| 136 | +specified in -l option is the source language, and the rest of languages |
| 137 | +are the translation target languages. |
| 138 | +``` |
| 139 | +java -jar gp-cli.jar create -b MyNewBundle -l en,fr,de -j mycreds.json |
| 140 | +``` |
| 141 | + |
| 142 | +#### import |
| 143 | + |
| 144 | +Imports resource data to a bundle. This command takes an input language. |
| 145 | +If the language does not exist in the bundle, the language will be |
| 146 | +automatically added to the bundle configuration. |
| 147 | + |
| 148 | +There are several different resource types available: |
| 149 | + |
| 150 | +* **JAVA** - Java property resource bundle file |
| 151 | +* **JSON** - Resource string key/value pairs stored in JSON format. For now nested JSON object is not supported. |
| 152 | +* **AMDJS** - RequireJS I18N bundle file |
| 153 | +* **IOS** - iOS String Resource file |
| 154 | +* **ANDROID** - Android String Resource file |
| 155 | +* **PO** - GNU Gettext portable object file |
| 156 | +* **POT** - GNU Gettext portable object template file |
| 157 | +* **YML** - YAML resoruce bundle file |
| 158 | +* **XLIFF** - XLIFF file (Not fully implemented) |
| 159 | + |
| 160 | +For example, the followng example imports English (en) resource strings in Java properties |
| 161 | +file *MyBundle.properties* to the bundle *MyBundle*. |
| 162 | +``` |
| 163 | +java -jar gp-cli.jar import -b MyBundle -l en -t JAVA -f MyBundle.properties -j mycreds.json |
| 164 | +``` |
| 165 | + |
| 166 | +#### export |
| 167 | + |
| 168 | +Exports the contents of bundle to a resource bundle file. The supported resource |
| 169 | +bundle types are same with the import command. |
| 170 | + |
| 171 | +For example, the following example exports French (fr) resource strings from the bundle |
| 172 | +*MyBundle* to the Java property file *MyBundle_fr.properties*. |
| 173 | +``` |
| 174 | +java -jar gp-cli.jar export -b MyBundle -l fr -t JAVA -f MyBundle_fr.properties |
| 175 | +``` |
| 176 | + |
| 177 | +If you have the original (source) resource bundle file, and you want to keep the |
| 178 | +original format including the order of resource keys, comments and others, -o option might |
| 179 | +be used. This feature is not supported by some resoruce types such as JSON. |
| 180 | + |
| 181 | +When translated resource string value is not available, the export command does not |
| 182 | +include the resource key in the output by default. If you want to include such resource |
| 183 | +key with the value from the source language, you can specify -k option. |
| 184 | + |
| 185 | + |
| 186 | +#### delete (delete-bundle) |
| 187 | + |
| 188 | +Deletes a bundle. The following example deletes a bundle *MyBundle* from |
| 189 | +your service instance. |
| 190 | +``` |
| 191 | +java -jar gp-cli.jar delete -b MyBundle -j mycreds.json |
| 192 | +``` |
| 193 | + |
| 194 | +#### copy (copy-bundle) |
| 195 | + |
| 196 | +Creates a copy of the specified bundle. This command allows you to duplicates a |
| 197 | +bundle in the same service instance, or another service instance. |
| 198 | +The following example copies the contents of exiting bundle *MyBundle* to |
| 199 | +a new bundle *MyNewBundle* in the same service instance. |
| 200 | +``` |
| 201 | +java -jar gp-cli.jar copy -b MyBundle -d MyNewBundle -j mycreds.json |
| 202 | +``` |
| 203 | +This command can be used to duplicate a bundle from a service instance to |
| 204 | +another service instance. In this case, you need to specify the destination instance's |
| 205 | +credentials with --dest-* options as below. |
| 206 | +``` |
| 207 | +java -jar gp-cli.jar copy -b MyBundle -d MyBundle --dest-url https://gp-rest.ng.bluemix.net/translate/rest --dest-instance-id 9146abf71bb94513504a0eaf76d57804 --dest-user-id 52858e19ae57ba6f2d2ea7e38e9ab457 --dest-password o75YXQCK2obQLOvedkSslBTAyeUq7/+t -j mycreds.json |
| 208 | +``` |
| 209 | +Note: This command does not copy service managed properties, such as |
| 210 | +updatedBy and updatedAt stored in each entity. The newly copied bundle |
| 211 | +and resource entries will have new timestamp in updatedAt property |
| 212 | +and the operator of this command will be set to updatedBy property. |
| 213 | + |
| 214 | + |
| 215 | +#### copy-all-bundles |
| 216 | + |
| 217 | +Copies all bundles from a service instance to another. This command invokes |
| 218 | +*copy (copy-bundle)* operation for all bundles in the specified service |
| 219 | +instance. This command is convenient for moving all bundle data to a newly |
| 220 | +created instance. |
| 221 | +The following example copies all bundles in the service instance to |
| 222 | +another instance specified by --dest-instance-id. |
| 223 | +``` |
| 224 | +java -jar gp-cli.jar copy-all-bundles --dest-url https://gp-rest.ng.bluemix.net/translate/rest --dest-instance-id 9146abf71bb94513504a0eaf76d57804 --dest-user-id 52858e19ae57ba6f2d2ea7e38e9ab457 --dest-password o75YXQCK2obQLOvedkSslBTAyeUq7/+t -j mycreds.json |
| 225 | +``` |
| 226 | +Note: This command copies bundle data to the destination service instance, |
| 227 | +but user accounts and translation configurations are not transferred, because |
| 228 | +they are service instance specific. |
| 229 | + |
| 230 | + |
| 231 | +--- |
| 232 | +### <a name="TOC-Cmd-User"></a>User Commands |
| 233 | + |
| 234 | +#### list-users |
| 235 | + |
| 236 | +Prints out a list of users in the service instance. |
| 237 | +``` |
| 238 | +java -jar gp-cli.jar list-users -j mycreds.json |
| 239 | +``` |
| 240 | + |
| 241 | + |
| 242 | +#### create-user |
| 243 | + |
| 244 | +Creates a new user in the service instance. |
| 245 | + |
| 246 | +The example below creates a new |
| 247 | +user account with read-only access to the bundles *MyAppsBundle1* and |
| 248 | +*MyAppsBundle2*. |
| 249 | +``` |
| 250 | +java -jar gp-cli.jar create-user -t READER -b MyAppsBundle1,MyAppsBundle2 -j mycreds.json |
| 251 | +``` |
| 252 | +The output of above command looks like below. |
| 253 | +``` |
| 254 | +A new user was successfully created. |
| 255 | +User ID: 9b8b65c31cf56a8eac2bd4a1a1f09175 |
| 256 | +User password: IpBiOP0s4xXs3SRSgofYLLasU6/qEWFf |
| 257 | +``` |
| 258 | +Note: The password above cannot be retrieved from the service later. |
| 259 | +If you lost the password, you can only reset the password by |
| 260 | +*reset-user-password* command below. |
| 261 | + |
| 262 | +The command option -t specifies a type of new user. There are |
| 263 | +following user types. |
| 264 | +* **ADMINISTRATOR** - Administrator of the service instance. |
| 265 | +* **TRANSLATOR** - Can read bundles and edit tranlations. This account type |
| 266 | +is designed for external tooling for translators. |
| 267 | +* **READER** - Can only read basic information of bundles and resource strings. |
| 268 | +This account type is designed for distributing credentials included in a client |
| 269 | +application accessing the translated strings dynamically. |
| 270 | + |
| 271 | + |
| 272 | +#### reset-user-password |
| 273 | + |
| 274 | +Resets a user's password. The example below resets the password of the |
| 275 | +user whose ID is 9b8b65c31cf56a8eac2bd4a1a1f09175. |
| 276 | +``` |
| 277 | +java -jar gp-cli.jar reset-user-password -d 9b8b65c31cf56a8eac2bd4a1a1f09175 -j mycreds.json |
| 278 | +``` |
| 279 | +The out of above command looks like below. |
| 280 | +``` |
| 281 | +New password: CD0ZPBvOoTCZbDCDssY/sMEjmTvW+rYs |
| 282 | +``` |
| 283 | + |
| 284 | + |
| 285 | +#### delete-user |
| 286 | + |
| 287 | +Deletes a user. The example below delets the user whose ID is |
| 288 | +9b8b65c31cf56a8eac2bd4a1a1f09175. |
| 289 | +``` |
| 290 | +java -jar gp-cli.jar delete-user -d 9b8b65c31cf56a8eac2bd4a1a1f09175 -j mycreds.json |
| 291 | +``` |
| 292 | + |
| 293 | +--- |
| 294 | +### <a name="TOC-Cmd-Others"></a>Other Commands |
| 295 | + |
| 296 | +#### list-mt-languages |
| 297 | + |
| 298 | +Prints out machince translation languages currently enabled in the |
| 299 | +service instance. For example, the following example prints out an array |
| 300 | +of machine translation target languages from English (en). |
| 301 | +``` |
| 302 | +java -jar gp-cli.jar list-mt-languages -f en -j mycreds.json |
| 303 | +``` |
| 304 | +The output of above command looks like below. |
| 305 | +``` |
| 306 | +["de","es","fr","it","ja","ko","pt-BR","zh-Hans","zh-Hant"] |
| 307 | +``` |
| 308 | + |
| 309 | +--- |
| 310 | +## <a name="TOC-How-To"></a>How-To |
| 311 | + |
| 312 | +### <a name="TOC-Import-Existing-Translations"></a>Import Existing Translations |
| 313 | + |
| 314 | +You may already have resource bundles translated from English to several |
| 315 | +different languages. If you want to import the already translated contents to |
| 316 | +a Globalization Pipeline service bundle, then you can follow the steps below. |
| 317 | + |
| 318 | +1\. Create a new bundle with English as the source language. In this example, |
| 319 | +we use *com.ibm.example.MyBundle* as the bundle ID. |
| 320 | +``` |
| 321 | +java -jar gp-cli.jar create -b com.ibm.example.MyBundle -l en -j mycreds.json |
| 322 | +``` |
| 323 | + |
| 324 | +2\. Import the English(en) resource bundle contents to *MyBundle*. The resource bundle |
| 325 | +file in this example is a Java properties fiel - MyBundle.properties |
| 326 | +``` |
| 327 | +java -jar gp-cli.jar import -b com.ibm.example.MyBundle -l en -t JAVA -f MyBundle.properties -j mycreds.json |
| 328 | +``` |
| 329 | +At this point, the bundle *com.ibm.example.MyBundle* in the Globalization |
| 330 | +Pipeline service instance contains only English resource strings. |
| 331 | + |
| 332 | +3\. Import the corresponding translated version. In this example, the operation |
| 333 | +below imports French(fr) translation from MyBundle_fr.properties. |
| 334 | +``` |
| 335 | +java -jar gp-cli.jar import -b com.ibm.example.MyBundle -l fr -t JAVA -f MyBundle_fr.properties -j mycreds.json |
| 336 | +``` |
| 337 | +This operation automatically adds French to the bundle *com.ibm.example.MyBundle*. |
| 338 | + |
| 339 | +4\. Repeat step 3 above for other translated versions. |
| 340 | + |
| 341 | + |
| 342 | + |
| 343 | + |
| 344 | + |
0 commit comments