site  contact  subhomenews

Started developing automatic language translation

January 06, 2023 — BarryK

The folder for this new project is /usr/local/translation, and the first script is 'translate-string'.
It will read a sentence in English, from /tmp/translate-shell/en-input-string, the script is called passing the target language on the commandline, for example:

# /usr/local/translate/translate-string fr

And the translated sentence will be in /tmp/translate-shell/translated-output-string. For example, here is English input and French output:

The EasyOS operating system has now released version ${VER} and this is great, download from
Le système d’exploitation EasyOS a maintenant publié la version ${VER} et c’est génial, télécharger depuis

The trick in the script is that it forces certain strings to not be translated. In the above example, that is "EasyOS", "${VER}" and ""

The method used to exclude certain strings is by means of a list of regular expressions, in file /usr/local/translate/keep-patterns. Strings that are not to be translated are converted to an untranslatable string by use of 'base32' utility.

I posted about using 'base32' in the Puppy Forum:

The script uses 'translate-shell', project page:

...which can use different translation engines. The default is "google"; however, I found that "bing" does a better job. The google engine was limiting translation to 178 characters -- searched online, could nowhere find that limit mentioned. OK, I'm using it for free, and there is a daily limit I think, so maybe that's it. Maybe I hit the daily limit and it truncated my translation to only 178 characters.    

Tags: easy