LilyPond Contributor's Guide: 5.9.3 Documentation translation maintenance

### 5.9.3 Documentation translation maintenance

Several tools have been developed to make translations maintenance easier. These helper scripts make use of the power of Git, the version control system used for LilyPond development.

You should use them whenever you would like to update the translation in your language, which you may do at the frequency that fits your and your cotranslators’ respective available times. In the case your translation is up-to-date (which you can discover in the first subsection below), it is enough to check its state every one or two weeks. If you feel overwhelmed by the quantity of documentation to be updated, see Maintaining without updating translations.

#### Check state of translation

Note: Translation helper scripts will work only if you’ve configured lilypond to be built in-tree, as explained in Running `autogen.sh`.

First pull from Git – see Git cheat sheet, but DO NOT rebase unless you are sure to master the translation state checking and updating system – then cd into ‘`Documentation/`’ (or at top of the source tree, replace `make` with `make -C Documentation`) and run

>     make ISOLANG=MY_LANGUAGE check-translation

This presents a diff of the original files since the most recent revision of the translation and prints it to terminal output. Usually you’ll want to pass this output to a terminal pager like `less` in order to scroll the diff up and down:

>     make ISOLANG=MY_LANGUAGE check-translation | less -R

To check a single file, cd into ‘`Documentation/`’ and run

>     make TRANSLATION_FILES=MY_LANGUAGE/manual/foo.itely check-translation

In case this file has been renamed since you last updated the translation, you should specify both old and new file names, e.g. `TRANSLATION_FILES=MY_LANGUAGE/{manual,user}/foo.itely`.

To see only which files need to be updated, do

>     make ISOLANG=MY_LANGUAGE check-translation | grep -n 'diff --git'

The `-n` option of `grep` will print the line number of each occurrence, which can be used to have an idea of the length of each diff and the amount of work required.

To avoid printing terminal colors control characters, which is often desirable when you redirect output to a file, run

>     make ISOLANG=MY_LANGUAGE NO_COLOR=1 check-translation

You can see the diffs generated by the commands above as changes that you should make in your language to the existing translation, in order to make your translation up to date.

Note: do not forget to update the committish in each file you have completely updated, see Updating translation committishes.

#### See also

Maintaining without updating translations.

#### Updating documentation translation

Instead of running `check-translation`, you may want to run `update-translation`, which will run your favorite text editor to update files. First, make sure environment variable `EDITOR` is set to a text editor command, then run from ‘`Documentation/`’

>     make ISOLANG=MY_LANGUAGE update-translation

or to update a single file

>     make TRANSLATION_FILES=MY_LANGUAGE/manual/foo.itely update-translation

For each file to be updated, `update-translation` will open your text editor with this file and a diff of the file in English; if the diff cannot be generated or is bigger than the file in English itself, the full file in English will be opened instead.

Note: do not forget to update the committish in each file you have completely updated, see Updating translation committishes.

‘`.po`’ message catalogs in ‘`Documentation/po/`’ may be updated by issuing from ‘`Documentation/`’ or ‘`Documentation/po/`’

>     make po-update

Note: if you run po-update and somebody else does the same and pushes before you push or send a patch to be applied, there will be a conflict when you pull. Therefore, it is better that only the Translation meister runs this command. Furthermore, it has been borken since the GDP: variable names and comments do no longer appear as translated.

Updating music snippets can quickly become cumbersome, as most snippets should be identical in all languages. Fortunately, there is a script that can do this odd job for you (run from ‘`Documentation/`’):

>     make ISOLANG=MY_LANGUAGE snippet-update

This script overwrites music snippets in ‘`MY_LANGUAGE/foo/every.itely`’ with music snippets from ‘`foo/every.itely`’. It ignores skeleton files, and keeps intact music snippets preceded with a line starting with `@c KEEP LY`; it reports an error for each ‘`.itely`’ that has not the same music snippet count in both languages. Always use this script with a lot of care, i.e., run it on a clean Git working tree, and check the changes it made with `git diff` before committing; if you don’t do so, some `@lilypond` snippets might be broken or make no sense in their context.

#### See also

Maintaining without updating translations, Adding and editing snippets.

#### Updating translation committishes

At the beginning of each translated file except PO files, there is a committish which represents the revision of the sources which you have used to translate this file from the file in English.

When you have pulled and updated a translation, it is very important to update this committish in the files you have completely updated (and only these); to do this, first commit possible changes to any documentation in English which you are sure to have done in your translation as well, then replace in the up-to-date translated files the old committish by the committish of latest commit, which can be obtained by doing

>     git rev-list HEAD |head -1

Most of the changes in the LSR snippets included in the documentation concern the syntax, not the description inside `texidoc=""`. This implies that quite often you will have to update only the committish of the matching .texidoc file. This can be a tedious work if there are many snippets to be marked as up do date. You can use the following command to update the committishes at once:

>     cd Documentation/LANG/texidocs
>     sed -i -r 's/[0-9a-z]{40}/NEW-COMMITTISH/' *.texidoc

#### See also

LSR work.

#### Maintaining without updating translations

Keeping translations up to date under heavy changes in the documentation in English may be almost impossible, especially when a lot of contributors brings changes.

It is possible — and even recommended — to perform some maintenance that keeps translated documentation usable and eases future translation updating. The rationale below the tasks list motivates this plan.

The following tasks are listed in decreasing priority order.

1. Update macros.itexi. For each obsolete macro definition, if it is possible to update macro usage in documentation with an automatic text or regexp substitution, do it and delete the macro definition from ‘`macros.itexi`’; otherwise, mark this macro definition as obsolete with a comment, and keep it in ‘`macros.itexi`’ until the documentation translation has been updated and no longer uses this macro.
2. Update ‘`*.tely`’ files completely with `make check-translation` – you may want to redirect output to a file because of overwhelming output, or call check-translation.py on individual files, see Check state of translation.
3. In ‘`.itelys`’, match sections and .itely file names with those from English docs, which possibly involves moving nodes contents in block between files, without updating contents itself. In other words, the game is catching where has gone each section. In Learning manual, and in Notation Reference sections which have been revised in GDP, there may be completely new sections: in this case, copy `@node` and `@section`-command from English docs, and add the marker for untranslated status `@untranslated` on a single line. Note that it is not possible to exactly match subsections or subsubsections of documentation in English, when contents has been deeply revised; in this case, keep obsolete (sub)subsections in the translation, marking them with a line `@c obsolete` just before the node.

   Emacs with Texinfo mode makes this step easier:

   - without Emacs AucTeX installed, <C-c C-s> shows structure of current Texinfo file in a new buffer `*Occur*`; to show structure of two files simultaneously, first split Emacs window in 4 tiles (with <C-x 1> and <C-x 2>), press <C-c C-s> to show structure of one file (e.g., the translated file), copy `*Occur*` contents into `*Scratch*`, then press <C-c C-s> for the other file.

     If you happen to have installed AucTeX, you can either call the macro by doing <M-x texinfo-show-structure> or create a key binding in your ‘`~/.emacs`’, by adding the four following lines:

     >     (add-hook 'Texinfo-mode-hook
     >               '(lambda ()
     >                  (define-key Texinfo-mode-map "\C-cs"
     >                   'texinfo-show-structure)))

     and then obtain the structure in the `*Occur*` buffer with <C-c s>.

   - Do not bother updating `@menu`s when all menu entries are in the same file, just do <C-c C-u C-a> (“update all menus”) when you have updated all the rest of the file.
   - Moving to next or previous node using incremental search: press <C-s> and type `node` (or <C-s @node> if the text contains the word ‘node’) then press <C-s> to move to next node or <C-r> to move to previous node. Similar operation can be used to move to the next/previous section. Note that every cursor move exits incremental search, and hitting <C-s> twice starts incremental search with the text entered in previous incremental search.
   - Moving a whole node (or even a sequence of nodes): jump to beginning of the node (quit incremental search by pressing an arrow), press <C-SPACE>, press <C-s node> and repeat <C-s> until you have selected enough text, cut it with <C-w> or <C-x>, jump to the right place (moving between nodes with the previous hint is often useful) and paste with <C-y> or <C-v>.
4. Update sections finished in the English documentation; check sections status at

       https://lilypondwiki.tuxfamily.org/index.php?title=Documentation_coordination.

5. Update documentation PO. It is recommended not to update strings which come from documentation that is currently deeply revised in English, to avoid doing the work more than once.
6. Fix broken cross-references by running (from ‘`Documentation/`’)

   >     make ISOLANG=YOUR-LANGUAGE fix-xrefs

   This step requires a successful documentation build (with `make doc`). Some cross-references are broken because they point to a node that exists in the documentation in English, which has not been added to the translation; in this case, do not fix the cross-reference but keep it "broken", so that the resulting HTML link will point to an existing page of documentation in English.

#### Rationale

You may wonder if it would not be better to leave translations as-is until you can really start updating translations. There are several reasons to do these maintenance tasks right now.

- This will have to be done sooner or later anyway, before updating translation of documentation contents, and this can already be done without needing to be redone later, as sections of documentation in English are mostly revised once. However, note that not all documentation sectioning has been revised in one go, so all this maintenance plan has to be repeated whenever a big reorganization is made.
- This just makes translated documentation take advantage of the new organization, which is better than the old one.
- Moving and renaming sections to match sectioning of documentation in English simplify future updating work: it allows updating the translation by side-by-side comparison, without bothering whether cross-reference names already exist in the translation.
- Each maintenance task except ‘Updating PO files’ can be done by the same person for all languages, which saves overall time spent by translators to achieve this task: the node names and section titles are in English, so you can do. It is important to take advantage of this now, as it will be more complicated (but still possible) to do step 3 in all languages when documentation is compiled with `texi2html` and node names are directly translated in source files.

#### LilyPond — Contributor’s Guide v2.24.4 (stable-branch).