| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # XTM Integration | |
| 2 | |
| 3 The integration with the XTM API can be run using the following command: | |
| 4 | |
| 5 python -m cms.bin.xtm_translations [-h] [-v] {login,create,upload,download} | |
| 6 | |
| 7 | |
| 8 and it has four main operational modes: | |
| 9 | |
| 10 | |
| 11 ### 1. XTM Login | |
|
Vasily Kuznetsov
2018/10/05 10:56:26
In other parts of CMS documentation we use second
Tudor Avram
2018/10/05 12:34:41
Done.
| |
| 12 This mode prompts the user for the login credentials and prompts | |
| 13 the API for the authentication token. This token should then be saved as an | |
| 14 environment variable to be used in the other modes. It can be run as follows: | |
| 15 | |
| 16 | |
| 17 python -m cms.bin.xtm_translations [-h] [-v] login [-h] | |
| 18 | |
| 19 | |
| 20 | |
| 21 ### 2. Project Creation | |
| 22 In this mode, one can create an XTM project. It can be run as follows: | |
| 23 | |
| 24 | |
| 25 python -m cms.bin.xtm_translations [-h] [-v] create [-h] --name NAME | |
| 26 --desc DESC --client-id CLIENT_ID --ref-id REF_ID | |
| 27 --workflow-id WORKFLOW_ID [--source-lang SOURCE_LANG] | |
| 28 [--save-id] [source_dir] | |
| 29 | |
| 30 | |
| 31 where: | |
| 32 * --name* = The name of the project will have once created. | |
| 33 * *--desc** = The description you wish to add to the project. | |
| 34 * *--client-id** = The id of the **pre-configured** XTM client you want | |
| 35 associated with the project. Has to be an integer! | |
| 36 * *--ref-id** = The reference id you want associated with the XTM project. | |
| 37 * *--workflow-id** = The id of the **pre-configured** XTM workflow to be | |
| 38 associated with the project. Has to be an integer! | |
| 39 * *--source-lang* = The language of the source files. If not provided, | |
| 40 the script will use `en_US` by default. | |
| 41 * *--save-id* = Whether to save the id of the newly created project into | |
| 42 'settings.ini' or not. | |
| 43 * *source_dir* = The source directory of the website. If not specified, the | |
| 44 script would consider the current working directory as the source for the websit e. | |
| 45 It will be used to extract all the translation strings and create the files | |
| 46 to be uploaded on project creation. It will also be used to automatically | |
| 47 detect the target languages for this specific project. | |
| 48 | |
| 49 **Note:** All arguments marked with * are **mandatory** and the script will | |
| 50 fail if not provided. | |
| 51 | |
| 52 In order for this mode to work, it requires the XTM authentication token | |
| 53 to be saved in the `XTM_TOKEN` environment variable. | |
| 54 | |
| 55 | |
| 56 ### 3. File Uploading | |
| 57 This mode can be used to upload new files for translation to an existing project . | |
| 58 It can be run as follows: | |
| 59 | |
| 60 | |
| 61 python -m cms.bin.xtm_translations [-h] [-v] upload [-h] [--no-overwrite] | |
| 62 [source_dir] | |
| 63 | |
| 64 | |
| 65 where: | |
| 66 * *--no-overwrite* = If this flag is set, then the script would **create new | |
| 67 files** in XTM, instead of overwriting the ones that were already there. | |
| 68 * *source_dir* = The source directory of the website. See above for the full | |
| 69 explanation. | |
| 70 | |
| 71 If you wish to add a new target language to the project automatically, | |
| 72 simply create a corresponding directory in the website's `locales` directory | |
| 73 and the script will update the XTM project accordingly before uploading the | |
| 74 new files and will create jobs for the new languages as well. | |
| 75 | |
| 76 In order for this mode to work, it requires two things to be present: | |
| 77 1. The XTM authentication token saved in the `XTM_TOKEN` environment variable. | |
| 78 2. The XTM project number present in `settings.ini`, under the `project_id` | |
| 79 option, in the `XTM` section. | |
| 80 | |
| 81 | |
| 82 ### 4. Translation Files Downloading | |
| 83 This mode downloads the translation files from the XTM project and saves them | |
| 84 in the website's `locales` directory. It can be run as follows: | |
| 85 | |
| 86 python -m cms.bin.xtm_translations [-h] [-v] download [-h] [source_dir] | |
| 87 | |
| 88 | |
| 89 where `source_dir` is the source directory of the website. See above for full | |
| 90 explanation. | |
| 91 | |
| 92 When run in this mode, the script will remove all the translation files that | |
| 93 were previously saved locally and then save the new ones in their place. | |
| 94 | |
| 95 In order for this mode to work, three requirements need to be fulfilled: | |
| 96 1. The XTM authentication token saved in the `XTM_TOKEN` environment variable. | |
| 97 2. The XTM project number present in `settings.ini`, under the `project_id` | |
| 98 option, in the `XTM` section. | |
| 99 3. (At least one) translation file(s) to be present in XTM. | |
| OLD | NEW |