This script allows to export strings (stories) from InDesign files (currently only IDML
format is supported) to JSON
in an i18next compatible format, so as to allow for translation of such strings / stories to other languages.
Once translated, the JSON
file with the translated strings can be re-imported to a new IDML
file that is copied from the original source file,
and you will have a translated copy of the source file.
- Download and install NodeJS. Click here to download NodeJS.
- Use git to checkout this repo
- Run
npm install
from the command line once inside the repo folder
- The graphic designer creates the original Indesign file, keeping in mind to avoid adding full line breaks in the middle of sentences (soft breaks with Shift + Enter are acceptable, this will insert a 'Line separator' character, but should be used sparingly, only when an actual newline is required).
- A folder for the project should be created inside the
input
folder (go ahead and create theinput
folder if it doesn't exist yet). If for example the project is called 'Catalogo2022', place the Indesign sourceIDML
file inindesign-translate/input/Catalogo2022/sourcelang.idml
. TheIDML
file here must be named with the two letter ISO code of the source language, for example (it.idml
, oren.idml
etc.). This is important, because the scripts will pick up the source language from the name of the file. - A script is run to extract the Source text from the
idml
file for translation:npm run extract
. This script will create atranslation.json
file in thetranslate_json
folder (will be automatically created if it doesn't exist), under a subfolder with the same name as the project and a subfolder corresponding to the source language. For example,indesign-translate/translate_json/Catalogo2022/it/translation.json
. - A Github repository should be created for the extracted source (in the example, a repository should be initialized in
indesign-translate/translate_json/Catalogo2022
), and a Weblate project for that repository should be created. - Translation can be done directly in the Weblate interface for the project, and Weblate will take care of sending translations back to the Github repository.
- Once translations are complete, and all translations have been commmitted back to the Github repository, and all Pull Requests have been resolved, the local repository should by synchronized with the remote Github repository using
git pull
. - A script is then used to generate an InDesign file (in
IDML
format) for each language for which we have translations:npm run translate
. This will generate anIDML
file for each language in theoutput
folder (will be created if it doesn't exist), under a subfolder with the same name as the project. For example,indesign-translate/output/Catalogo2022/en.idml
,indesign-translate/output/Catalogo2022/fr.idml
. - These InDesign files must be opened in InDesign to check for any manual adjustments needed. Font sizes may need to be adjusted, text boxes may need to be resized, boxes may require rearranging (for example, in English adjectives precede nouns, whereas in other languages adjectives may sometimes follow a noun; if the adjective and the noun are in separate text boxes, the order of the text boxes may need some rearrangement).
- Once the translated file has been reviewed in InDesign it is ready to be exported as a PDF.
What should the graphic designer keep in mind when creating the original InDesign file, so as to support translation?
- English is a relatively compact language. For short peices of text assume that other languages could be up to 300% more characters, and for longer sections up to 170% more characters.
- Expand text boxes as much as possible to support more characters than is in the English version.
- For each story expand the story editor to take up the full width of the screen, and turn on the end of line symbol in the story editor. We want to make sure that each sentence that should be translated as one sentence does not have an unnecessary line break.
- Avoid adjusting the format of specific pieces of text within a story as this causes that piece of text to have to be translated seperately from the rest of the sentence, in order to maintain the formatting.
- For the same reason DO NOT USE KERNING. Kerning results in each indivual letter needing translation.
- If any changes are made to the original InDesign file after the translation process has started, it should be saved in IDML format in the project subfolder, under the
input
folder (for exampleindesign-translate/input/Catalogo2022/it.idml
). - Run the extraction script again, to update the source
translation.json
file:npm run extract
. - In the project folder under
translate_json
, make sure all updates from Github have been imported (run agit pull
), then commit the changes to the sourcetranslation.json
and push to the remote Github repo, for example:cd translate_json/Catalogo2022 git pull git add it/translation.json git commit -m "updated the source texts" git push
- If a weblate webhook has been set up on the Github repository, Weblate will immediately see the changes and adjust all the translation files to reflect the changes in the source file. This may then require reviewing all the language translations, accepting suggestions from previously translated strings that may have new keys to identify them.