Sample Scripts
Aaron Sakievich (Unlicensed)
Kenny Teves
Note: this is as of LTK version 1.3.5
Key
red text
= this is an example of what might be shown, but the actual values may be different for you
bold blue text
= these are ltk commands
blue text = these are user inputs to prompts. Your inputs may be different
green text = these are file and directory paths
bold text = this is terminology that is being defined
Setting Up Your Project
You need to set up an ltk project before you can send any content to Enterprise for translation. An ltk project consists of 1.) a set of configurations for the filesystem connector, and 2.) local tracking of documents that the project is managing. Local tracking allows users to only add documents to the project that they want the project to manage. The documents in local tracking should match up with the documents in the Enterprise project connected to the ltk project (see the example "ltk init" procedure below), but this is not guaranteed as uploads may fail or the Enterprise project can be modified from other sources without the ltk project knowing about it. There are commands that can bring the ltk project back into sync with the Enterprise project, but those aren't in the scope of these basic examples and will just be explained briefly at the end. The command for setting up an ltk project is ltk init
. This will take you through a wizard to configure the project. In this example, we are going to create an ltk project in the directory ~/myproject. This makes ~/myproject the root of the project. You must be in the root of the project or in a subdirectory of the root for the filesystem connector to work. The following is an example of what using ltk init
would look like:
cd ~/myproject
//we are going to use "~/myproject" as the project rootltk init
The init wizard will have the following sections:---------------------------
SELECT Enterprise COMMUNITY
---------------------------
ID Name UUID
---- ------------------ ------------------------------------
0 My Community 01234567-89ab-cdef-0123-456789abcdef
1 My Other Community abcdef98-7654-3210-abcd-ef9876543210
Select
Enterprise
Community ID: 0
Enter the ID of the Enterprise Community you want to connect to. In this example, we are connecting to "My Community"
---------------------------SELECT EnterprisePROJECT
---------------------------
ID Name UUID
---- ---------------------- ------------------------------------
0 My Enterprise Project acebdf09-1234-4321-acdf-987697aed08f
1 Other Enterprise Project 55555555-5555-5555-5555-555555555555
2 YetAnotherProject 0a9b8c7d-6e5f-4321-1a2f-34678d9e0c8bSelect Project ID [create new]: 2
Enter the ID of the Enterprise Project you want to send documents to for translation. In this example, we are using the "YetAnotherProject" project in the "My Community" community. You can also just hit Enter with no input to create a new project in the "My Community" community and use it---------------------------
SELECT WORKFLOW TEMPLATE TO COPY AS A NEW PROJECT WORKFLOW
---------------------------
ID Name UUID
---- ---------------------- ------------------------------------
0 Machine Translation c675bd20-0688-11e2-892e-0800200c9a66
1 Translation + 1 review 2b5498e0-f3c7-4c49-9afa-cca4b3345af7
Select workflow ID [Project Default]: 0
Enter the ID of the workflow you want to use for your project. In this example, we are using the "Machine Translation" workflow. You can also just hit Enter with no input to use your selected project's workflow.
The workflow UUID you choose will be used to create a new Project Workflow (i.e. with an entirely new workflow UUID) on your new or existing project. We store the UUID of the original workflow template you chose in the config file but it is for informational purposes only. It is not referenced when uploading content to the TMS. If you chose to use the Project Default, then the existing project workflow is used and we store Project Default in the config file.
---------------------------
SET SOURCE LANGUAGE
---------------------------
Code Locale Name
------ -----------------------------
xx-XX Language, Country
en-GB English, United Kingdomen-US English, United States
en-ZA English, South Africa
es-AR Spanish, Argentina
es-ES Spanish, Spain
es-MX Spanish, Mexico
[many other languages]
What is the default locale for your source content? [en-US]:en-US
Enter the code for the locale that you expect your original content to be in. This is called the source locale. In this example, we plan to send documents that are in American English and have them translated into other languages. You can also just hit Enter with no input to use the default source language, which is American English (en-US)What default target locales would you like to translate into (eg. fr-FR, ja-JP)? [None]: es-MX, uk-UA, ko-KR
Enter the codes for the locales that you plan to translate your content into. These are called the target locales. In this example, we plan to translate our documents into Mexican Spanish (es-MX), Ukranian (uk-UA), and Korean (ko-KR). You can also just hit Enter with no input if you do not want to set any target locales at this time.Where would you like translations to be downloaded? [.]:
You can enter a directory that you want translations to be downloaded into. This will be the download folder. For example, if you set the download folder to ~/myproject/documents, and then uploaded ~/myproject/fileA.txt and ~/myproject/subdir1/fileB.txt, the translations for both fileA.txt and fileB.txt would be downloaded into ~/myproject/documents/. You can enter an absolute path or a path relative to the current directory, which in this case is ~/myproject. For instance, if you entered ~/myproject/subdir1/subdir2, it would be the same as entering subdir1/subdir2. If you just hit Enter with no input or enter the current directory, no download folder will be set and translations will end up downloading to the same location as their sources. For instance, if you uploaded ~/myproject/fileA.txt and ~/myproject/subdir1/fileB.txt, the translations for fileA.txt would be downloaded into ~/myproject/ and the translations for fileB.txt would be downloaded into ~/myproject/subdir1/. In this example, we just hit enter with no input, which doesn't set any download folder.Would you like to configure advanced options? [y/N]: N
The advanced options are git auto-commit, clone, auto-format, append, and download finalized file. In this example, we are skipping these by entering N, which just sets the default values. You can also just hit Enter with no input to skip the advanced options. The only option that we really care about in this example is the clone option. The default turns the clone option on, which changes the location that translations will be downloaded to. When clone is turned on, locale folders are created for each target locale when translations are downloaded, and the translations are put into those locale folders. The locale folders are created inside the download folder, or in the root of the project if no download folder is set. Because no download folder is set in this example, all Spanish translations will be downloaded into ~/myproject/es-MX, all Ukranian translations will be downloaded into ~/myproject/uk-UA, and all Korean translations will be downloaded into ~/myproject/ko-KR, even if the source documents were in other directories.
You can change the clone option and the download folder by using the ltk
config
command as follows:
ltk
config
-d --none
//unsets the download folderltk
config
-d /user/Myself/Documents/MyTranslations
//sets the download folder to /user/Myself/Documents/MyTranslationsltk
config
-c off
//turns the clone option offltk
config
-c on
//turns the clone option on
Round-Tripping Content
Key ltk Commands
Round-tripping refers to the whole process of uploading a document to Enterprise for translation, having it be translated, and then downloading the translations. The main ltk commands that will be used for this are ltk add
, ltk push
, ltk list
, ltk request
, ltk status
, and ltk pull
. There are other commands, which can be seen by running ltk -h, but in these basic examples we are going to stick with these six commands. The other commands will be briefly touched on later. The following examples will use the example setup explained in the section above and will assume that they are being run from the root of the project.
Examples of ltk addltk add
fileA.html
//uploads ~/myproject/fileA.html if it exists to the "YetAnotherProject" project in the "My Community" community in Enterprise and adds it to the ltk project's local tracking.ltk add
/user/Myself/MyDocuments/A*.txt
//uploads all files in /user/Myself/MyDocuments/ that start with "A" and end with ".txt" to Enterprise and adds them to local tracking.ltk add
subdir1/subdir2
//adds the folder ~myproject/subdir1/subdir2/ to local tracking, and uploads all files in that folder to Enterprise and adds them to local tracking as well.ltk add
//for all files in the root of the project that start with "fileA" and all files in ~myproject/subdir1/, adds them to Enterprise and adds them to local tracking. Also adds the folder ~myproject/subdir1/ to local tracking.~/myproject/fileA* subdir1
Examples of ltk pushltk push
//for all locally tracked files that have been modified since they were last added or pushed, updates the versions stored in the Enterprise project. For instance, if ~/myproject/fileA.txt contained the text "This is text" when it was added, the version in the Enterprise project would also say "This is text". If the contents of ~/myproject/fileA.txt were changed to be "New content", the version in the Enterprise project would still say "This is text". Running this command would update the version in Enterprise to match the local file and say "New content". It also adds files that are in locally tracked folders that might not have been added themselves. For example, if local tracking contains the files ~/myproject/file1.txt and ~/myproject/otherfiles/file2.txt and the folder ~/myproject/otherfiles/, but the local filesystem also had the files ~/myproject/otherfiles/file3.txt and ~/myproject/otherfiles/file4.txt, this command would add ~/myproject/otherfiles/file3.txt and ~/myproject/otherfiles/file4.txt to local tracking and upload them to Enterpriseltk push
-n
//lists the files that would be added and updated if this command had been run without the "-n" flag, but doesn't actually add or update them.
Examples of ltk listltk list
//lists all documents that are being locally tracked by the ltk project ltk list
-r
//lists all documents that can be found in the "YetAnotherProject" project in Enterprise. This is useful for finding out if all of the documents that you have added have successfully finished uploading yet
ltk list -l
//lists the locale codes for the languages that Enterprise supports. There are some cases where you need to input locale codes, and this will help you know which code to use for which language
Examples of ltk requestltk request
//begins the translation process into all default target locales for all locally tracked documents that have successfully been uploaded to Enterprise. In our example, this would start translating everything that's been added and successfully uploaded into Spanish, Ukranian, and Koreanltk request
de-DE
el-GR
//begins the translation process into German (de-DE) and Greek (el-GR) for all locally tracked documents that have successfully been uploaded to Enterprise
//begins the translation process into all default target locales for ~/myproject/textfile.txt. In this example, it would translate ~/myproject/textfile.txt into Spanish, Ukranian, and Korean, so long as ~/myproject/textfile.txt had been added and successfully uploaded first.
ltk request -p ~/myproject/textfile.txt
//same as the above example with the "-p" flag, except it uses a name instead of a filepath. Usually, the name is the name of the file itself, while the filepath includes the directories to reach that file. For example, a file with the path /user/Myself/MyDocuments/textfile.txt would have a name of "textfile.txt". However, because you can have a file with the same name stored at different filepaths, it's possible to add different files with the same name. Because of this, it is recommended to use the "-p" flag with a filepath instead of the "-n" flag with a name because you can be more explicit in specifying which document you want to request.ltk request
-n textfile.txt
ltk request -p subdir2/textfile2.txt de-DE el-GR
//begins the translation process into German (de-DE) and Greek (el-GR) for ~/myproject/subdir2/textfiles.txt, so long as it had been added and successfully uploaded first.
Examples of ltk statusltk status
//displays the overall completion percentage and status of each locally tracked document. A percentage of 100% or a status of COMPLETE means that all translations that have been requested are completed.ltk status
-d
//displays a more detailed breakdown of the completion percentages and statuses for each locally tracked document. This more detailed breakdown includes the completion percentage and status for each individual requested translation. For example, there could be a document that has been requested in Spanish, German, and Italian. If the Italian translation for that document is halfway done, the German translation is all the way done, and the Spanish translation hasn't been started yet, the overall document status will be IN PROGRESS, but the status for the German translation specifically will be COMPLETE
ltk status -n
//displays the overall completion percentage and status for the document with the name "textfile.txt". As explained above, it is possible to have duplicate names in local tracking and in the Enterprise project, so this should only be used if you are sure that there are no duplicate names. This also assumes that a file with the name "textfile.txt" has been added to the ltk project alreadytextfile.txt
ltk status
-n
//displays the more detailed breakdown of the completion percentages and statuses for each requested translation for the document with the name "textfile.txt". As explained above, it is possible to have duplicate names in local tracking and in the Enterprise project, so this should only be used if you are sure that there are no duplicate names. This also assumes that a file with the name "textfile.txt" has been added to the ltk project already
-d textfile.txt
Examples of ltk pullltk pull
//downloads all the translations from the Enterprise project for all locally tracked documents. If a translation has been started but is not yet complete, the incomplete file will still be downloaded. The download locations will depend on the config settings. See the above explanation of the example ltk project setup to see how the different config options affect the download locations. If the clone option is turned on, the filenames of the translated files will be the same as the source files. For example, the Japanese translation of a file named "file1.json" would still be named "file1.json". If the clone option is turned off, the filenames of the translated files will have the target locale appended to them. For example, the Japanese translation of a file named "file2.json" would have the name "file2.ja-JP.json".ltk pull
ko-KR uk-UA
//downloads the Korean and Ukranian translations from the Enterprise project for all locally tracked documents. If a translation has been started but is not yet complete, the incomplete file will still be downloaded. The download locations and file names will depend on the config settings.
Round-Tripping Examples
All of these examples use the ltk project setup demonstrated previously
Case 1:
I want to translate a single file from (American) English into all three of my target languages ((Mexican) Spanish, Ukranian, and Korean). I have never added anything before, so my local tracking is empty.
Source document location: ~/myproject/fileA.txt
Desired translation locations: ~/myproject/es-MX/fileA.txt, ~/myproject/uk-UA/fileA.txt, ~/myproject/ko-KR/fileA.txt
Current directory: /users/Myself/
cd ~/myproject //change directory to the project root
ltk add fileA.txt //add the source document by using its path relative to the project root
ltk list -r //look for fileA.txt in the output to verify that it was sucessfully uploaded. If it is not in the output, wait a bit and re-run this command until it is before proceeding.ltk request //because the only added file is fileA.txt, we can just run this without specifying fileA.txt specifically
//give Enterprise time to translate the fileltk status //check on the status of fileA.txt. If it displays 100% (COMPLETE), it is ready to download. If it doesn't, wait a bit and re-run this command until it does before proceeding.
ltk pull //because the only added file is fileA.txt and we want all the translations, we can just run this without specifying fileA.txt or the translation locales specifically
Case 2:
I have a personal project called Alpha that I have stored in ~/myproject/alpha1.0 that contains multiple directories and multiple files. I want to translate everything in Alpha into German.
Source document locations: ~/myproject/alpha1.0/fileA.txt, ~/myproject/alpha1.0/sub1/fileB.txt, ~/myproject/alpha1.0/sub1/sub2/fileC.txt
Desired translation locations: ~/myproject/de-DE/fileA.txt, ~/myproject/de-DE/fileB.txt, ~/myproject/de-DE/fileC.txt
Current directory: ~/myproject