A script to help with translations

Hi,

twice a year we get thousands of strings for translation. On the one
hand this is good but translation of strings which we have translated
many times in the past is pretty boring. So I have written a python
script, which can translate strings using unique existing translations.
These are then uploaded using Pootle. Its functionality is similar to
two tools from the translate toolkit: pretranslate and poconflicts. I do
not use these, because: pretranslate requires pot files (we do not have
them) and produces fuzzy translations, which we do not want. poconflicts
lists all conflicts, the script lists just those relevant to the
actually needed translations (I plan to use poconflits later to fix
conflicts).

The script is attached (I hope we can attach stuff here).

How to use:

1. Download existing translations from Pootle (master as well as the
previous version)

2. translate using:

./selftranslate.py -i idir -o odir

where idir is directory with po files to be translated. The output odir
contains only files with changes which can be uploaded to pootle. In
this case idir is used also as the source for translated strings. In our
case numerous translations may be missing (they were probably deleted
when updating). You may use:

./selftranslate.py -i idir -r rdir -o odir

where rdir is directory with other translation downloaded from Pootle
(for example the previous version) (in my case additional 300 strings
were translated)

3. Upload to pootle: zip the odir directory and upload to Pootle

In Slovak translation there are quite some conflicting translatios. The
command

./selftranslate.py -i idir -g > conflicts.json

or

./selftranslate.py -i idir -r rdir -g > conflicts.json

outputs their list in the form (json)

{
  "Start": "Začiatok/Spustiť",
  "Spacing:": "Rozostupy:/Riadkovanie:",
  "Collapse": "Zbaliť/Zmrštiť zo strán"
}

where the alternative translations are separated by "/". Edit the file
by deleting bad translations. (outputs of the previous two commands
should be merged). If the conflict is OK or you do not know, just delete
the line.

Then, translate using

./selftranslate.py -i idir -r rdir -o odir -c fixed_conflicts.json

It will fix the conflicts in the json file, too.

In Slovak this has reduced the number of strings to translate to about 1/3.

When uploading, I always test if it works by uploading just one zipped
file (with its full path). I've never had any problems.

If you have questions, do not hesitate to ask :). The script was tested
on Linux and a few python packaged needed to be installed (using pip)

best

milos

Hi Milos,

(I'm not a translator, but...)
where are the scripts? If you have attached them to the mail, then they
are stripped by the mailing list.

Best upload them to e.g. GitHub. :wink:

Dennis

Hi,

twice a year we get thousands of strings for translation. On the one
hand this is good but translation of strings which we have translated
many times in the past is pretty boring. So I have written a python
script, which can translate strings using unique existing translations

.

These are then uploaded using Pootle. Its functionality is similar to
two tools from the translate toolkit: pretranslate and poconflicts. I

do

not use these, because: pretranslate requires pot files (we do not hav

e

them) and produces fuzzy translations, which we do not want. poconflic

ts

lists all conflicts, the script lists just those relevant to the
actually needed translations (I plan to use poconflits later to fix
conflicts).

The script is attached (I hope we can attach stuff here).

How to use:

1. Download existing translations from Pootle (master as well as the
previous version)

2. translate using:

./selftranslate.py -i idir -o odir

where idir is directory with po files to be translated. The output odi

r

contains only files with changes which can be uploaded to pootle. In
this case idir is used also as the source for translated strings. In o

ur

case numerous translations may be missing (they were probably deleted
when updating). You may use:

./selftranslate.py -i idir -r rdir -o odir

where rdir is directory with other translation downloaded from Pootle
(for example the previous version) (in my case additional 300 strings
were translated)

3. Upload to pootle: zip the odir directory and upload to Pootle

In Slovak translation there are quite some conflicting translatios. Th

e

command

./selftranslate.py -i idir -g > conflicts.json

or

./selftranslate.py -i idir -r rdir -g > conflicts.json

outputs their list in the form (json)

{
  "Start": "Začiatok/Spustiť",
  "Spacing:": "Rozostupy:/Riadkovanie:",
  "Collapse": "Zbaliť/Zmrštiť zo strán"
}

where the alternative translations are separated by "/". Edit the file
by deleting bad translations. (outputs of the previous two commands
should be merged). If the conflict is OK or you do not know, just dele

te

the line.

Then, translate using

./selftranslate.py -i idir -r rdir -o odir -c fixed_conflicts.json

It will fix the conflicts in the json file, too.

In Slovak this has reduced the number of strings to translate to about

1/3.

When uploading, I always test if it works by uploading just one zipped
file (with its full path). I've never had any problems.

If you have questions, do not hesitate to ask :). The script was teste

d

twice a year we get thousands of strings for translation.

This is not true since master project was created in pootle. This was
intruduced exact for this reason, to prevent a big string dump.

On the one
hand this is good but translation of strings which we have translated
many times in the past is pretty boring.

It definitely is, but that is not because you get new strings, but
rather that you still have old projects untranslated.

So I have written a python
script, which can translate strings using unique existing translations.

Again: this won't help with the new strings you get, as obviously
those have been changed/newly introduced.
It might come in helpful for projects having to catch up/not focusing
on master but translating the old projects in parallel.

These are then uploaded using Pootle. Its functionality is similar to
two tools from the translate toolkit: pretranslate and poconflicts. I do
not use these, because: pretranslate requires pot files (we do not have
them)

Again wrong, "templates" is a project in pootle just like the actual
languages. You can get the pot from pootle the same way as you get
your po files.

The script is attached (I hope we can attach stuff here).

Nope, list strips attachments.

[…] The output odir
contains only files with changes which can be uploaded to pootle.

But please double-check whether the script actually works for your
language/did what you expected it to do. Admins won't like to revert
your broken uploads :wink:

Also please double-check that you keep the correct directory hierarchy
when reuploading/don't upload those files as new files into the wrong
directory.

In
this case idir is used also as the source for translated strings. In our
case numerous translations may be missing (they were probably deleted
when updating). You may use:

./selftranslate.py -i idir -r rdir -o odir

Again no idea how that tool works, as the attachment was stripped, but
if a string is removed, it is not deleted from the po file completely,
but marked as obsolete (lines starting with #~) - so if you had it
translated before, but is now gone, you'll find it in the obsolete
sections.

3. Upload to pootle: zip the odir directory and upload to Pootle

See note above: please make sure to use the proper directory
layout/don't introduce additional subdirectories and the like.

./selftranslate.py -i idir -r rdir -g > conflicts.json

outputs their list in the form (json)

{
  "Start": "Začiatok/Spustiť",
  "Spacing:": "Rozostupy:/Riadkovanie:",
  "Collapse": "Zbaliť/Zmrštiť zo strán"
}

where the alternative translations are separated by "/".

This is suboptimal choice, as / might appear in regular translation.
I'd rather make the output a proper array of separate strings for the
alternative translations.

ciao
Christian