# Translation Files

## Structure

All the files in this directory should have the form:
    bt_<lang>.ts
where <lang> is a two-letter ISO 639-1 language code corresponding
to the target language of the translation.

## Updating

Never **EVER** update the .ts files directly. Always use the procedure below
to ensure that we do not need some complicated merging process between our
.ts files and the Launchpad translations. We will always assume that the
Launchpad translations are current and can directly overwrite the .ts files'
translations at any instant without fear of obliterating previous translations.

To update these language files, first get a current snapshot of the [Launchpad
translations](https://translations.launchpad.net/brewtarget/trunk/+export)
and extract them into lpad/.

1. Convert launchpad files to bt_*.ts files. E.g.

        $ lconvert lpad/bt-ca.po -o bt_ca.ts

2. Commit the result with the date that the .po files were exported from
   launchpad in the commit headline. This is so that we maintain a history
   of the files as they are on launchpad in case anything goes wrong and we
   need to revert them.

3. Run lupdate on bt_*.ts files

        $ lupdate -no-obsolete ../src/* ../ui/* -ts bt_*.ts

4. Create .pot and .po files to upload to launchpad

        $ lconvert bt_ca.ts -o lpad/bt-ca.po
        $ lconvert bt_cs.ts -o lpad/bt-cs.po
        ...
        $ lconvert bt_en.ts -o lpad/bt.pot
        $ cd lpad
        $ tar -czf bt.tar.gz *.po *.pot 

5. Upload to Launchpad.
  - First, need to 'approve' bt.pot in the upload queue and wait for it to
    properly upload. Then, for each .po file, select the 'bt' template and
    correct language before 'approving'.

6. Clean up.

        $ rm -rf lpad/bt.tar.gz

7. Commit the final resulting files in a second commit (do not amend previous
   commit).

## Merging

If for some reason you MUST merge translations (please avoid this), first
remove untranslated entries from the launchpad translations, or otherwise you
will obliterate current translations with empty strings.

    $ msgattrib --translated lpad/bt-ca.po -o lpad/bt-ca.po

Then, you can either use lconvert to convert the launchpad translation into a
.qph phrasebook and use 'Batch Translate' from linguist, or try to directly
merge via linguist. It is important that the new .po file is on the right as
an argument, as this will make the new translations the default when doing
the merge.

    $ lconvert bt_ca.ts lpad/bt-ca.po -o bt_ca.ts

