- This topic has 5 replies, 2 voices, and was last updated May 27-1:32 pm by Robin.
-
AuthorPosts
-
May 26, 2021 at 10:20 am #60154Member
Robin
”Messrs Moony, Wormtail, Padfoot, and Prongs
Purveyors of Aids to Magical Mischief-Makers
are proud to present…”Joking aside, this is simply a new creation for our growing collection of antiX Community tools.
antiX Community Multilanguage Translation Tool (aCMTT)
It is meant to online translate text paragraphes directly from desktop rather than having to open an internet browser beforehand and load a webpage by URL.
By now it is restricted to command line usage only, but a GUI is to come soon.
This tool comes again as a simple bash script, so you can peek inside nosey to see how all this magic works under the hood.
Installation instructions:
— Download latest Version (0.20) of aCMTT script from gitlab, save it and check its file integrity by typing
shasum -a 256 'antiX-Community-Translation-Tool.sh'
which should give you back the character shambles:
e4a4145cf24ce1c4d4f101fdc2e03a2ac96374112689b5bd80aaff4c606a1098
If the downloaded file was approved to be byte identical by carefully comparing the strings, copy it with sudo permissions to the system folder
sudo cp 'antiX-Community-Translation-Tool.sh' '/usr/local/bin/'
And make it executable by entering:
sudo chmod 755 '/usr/local/bin/antiX-Community-Translation-Tool.sh'— For more usage convenience you may want to download and add the file sudoers.d/antiX-contribs to your system. Check its integrity as before (sha256-sum: 61f56046561e129e89ca082cf3deba6af5de003ef9a783dd66d630eea10c3dae) and save it to
/etc/sudoers.d/antiX-contribs
This file adds ping command (used by aCMTT script) to sudoer exceptions, allowing ping command to be executed without need of password by ordinary user. If omitting this step you will always get asked for sudo password when requesting a translation.— Now please add an alias for aCMTT to allow script to comply to the syntax described in help files:
alias aCMTT='/usr/local/bin/antiX-Community-Translation-Tool.sh'— English language users (as all the other languages, but non English speaking people are used to this for a long time) need to install “.mo” language files to get program output translated to their language, since this script makes use of the wide range of capabilities of gettext, allowing programmers to use their native language for message strings in programs rather than a doggerel attempt of writing them in English.
en_GB language file (sha256.sum: 3bc4bac3ca8b6232e830917bc3422433ad78a6b381cc9bf702b338f969f137c5)
en_US language file (sha256.sum: c7f2b86edfef3367467ffc4fb0a624f6eeb52b39806bbc4b8d732a38c36e8364)
en (universal) language file (sha256.sum: 33548928ee348852b2ac4bec49d175d5cf3c4df4db920ede94c410577a5e869f)
Please check file integrity using shasum as before, and copy these files to the system folders
/usr/share/locale/<ll_CC>/LC_MESSAGES
replacing <ll_CC> in path by the actual language identifier corresponding to the language the .mo file contains. Please be aware all these files in any language do have the same filename, so don’t mix them up. They won’t work when renamed.Now everything should be prepared for a first run.
Usage instructions:
aCMTT -h
might be a good start. If you installed the required language files it should come up in your language and show you all your options.For a first check you might simply enter the command
aCMTT -s en-GB -t zh-CN -l "This is a fountain pen, so please don't spill the ink."and stare flabbergasted at the result coming up some seconds later on your command line.
(Make sure you are connected to internet beforehand). I’d bet you never would have thought of being able to translate to Chinese language that easily, eh? You may check the result by feeding the output back into another online translator, e.g. translate.google.com in your browser.You will probably notice the translation service provider will soon stop your exploration activities when not submitting a contact e-mail and your ip-address in each request. This can be achieved by using additional options, please refer to help text.
Please consider to create an aCMTT settings file first for improved user convenience by using -w and -f options. Then you won’t have to re-enter again and again all your personal default transmission settings, but simply use -f option to read your defaults from a configuration file. You can always check the contents of your configuration file using option -d
Also you should consider to set up a separate (disposable) email address account, since translation service provider in use asks for transmission of contact email address on each request to get response to translation requests of more than a few words per day only. For privacy reasons never hand out freely your personal email account address in use for your actual correspondence for things like registration purposes. Don’t misread, you don’t need to register at all at this translation service provider for aCMTT usage. Transmitting a valid contact email of yours on each translation request is sufficient.
The output of this script is meant to be scriptable. So it can be set up in a way (by using -r option) other scripts will be able to get the raw translated string output from it merely. In this use case you may want to check for success of translation by reading the variable $? with “0” meaning translation was processed and output can be considered as a valid translation string, whereas “1” means something went wrong, don’t rely on translation output. Use -v command line option to check what made the translation fail by examining debug output on terminal.
All aCMTT translations are performed by use of free api services of translation service provider translated.net by now. An option to make use of other translation service providers is in progress.
!!! PLEASE KEEP IN MIND ALL OF YOUR TEXTS SENT IN FOR TRANSLATION ARE TO BE CONSIDERED AS PUBLIC !!!And please, don’t forget to mumble silently “mischief managed!” after you are done 🙂
Windows is like a submarine. Open a window and serious problems will start.
May 26, 2021 at 11:02 am #60157MemberPPC
::Hi! Very nice idea! I’ve been testing a similar automatic translation tool, that translates text copied to the clipboard directly to the default OS language and presents the output in a yad window. It uses the “trans” command (instalable using the default repos: sudo apt-get install translate-shell)
My tiny GUI script:texto_original=$(xclip -selection c -o) texto_traduzido=$(trans -b -show-alternatives n "$texto_original") yad --title="Auto translator" --fixed --width=700 --height=480 --center --form --field=":TXT" "$texto_traduzido" --button="Ok"May 26, 2021 at 3:25 pm #60167MemberPPC
::@Robin- Using my script I translated most of your script transifex entries (I don’t speak german, so I know now Marcelo’s pain, translating from English to pt-br)- only the enormous entry will all the cli options remains unlocalized…
P.
May 26, 2021 at 4:29 pm #60168MemberRobin
::@PPC Many thanks for your effort. The big one is the most important one.
Please read carefully the comment I have written to this elephantine entry: you don’t need to translate from German language, you simply can use English as base in transifex:— Click on the gear symbol in upper right corner of transifex site when translating.
— Chose Entry “show source string in english (en)”
— From the upcoming menu chose the language English United Kingdom (en_GB), instead of English (en)Then you will see all source strings in English instead of German, since I have translated them to English language already before uploading.
Only trouble is that transifex can’t handle this correctly on its own. You have to set it up manually as described.
Dealing with different source languages within a project is that very basic stuff, and they (transifex) are not prepared for this, treating all source as universal English (en) only (or another specific language set up at project start)? Well, we have a workaround 🙂
Moreover you will need to activate the “raw” view to see the expressions within arrows, which are hidden in normal transifex view, as well as the correct number of “blanks”. This I have also described in the above mentioned comment, keyword is “editor preferences”.
Robin
P.S.: This way you can write your source strings in Portuguese language within your scripts; gettext is able to handle this flawlessly. For me it makes much more sense to have precisely expressed source strings in any language of the world rather than doggerel attempts of non native speaking programmers to express things in English language (I include myself explicitly under this statement).
Windows is like a submarine. Open a window and serious problems will start.
May 27, 2021 at 10:53 am #60272MemberPPC
::@Thanks for the transifex tip. I did not know that! I don’t have much free time, so I pasted the english translation and localized to pt-pt only very small parts of this entry… Is it me, at least one od the initial entries is (at least in the english version), kind of repeated, in a slĩghtly different description?
P.
May 27, 2021 at 1:32 pm #60292MemberRobin
::Which one do you refer to? There are some entries which are treating identical tasks, the differences between them are details. Example:
-d --display-settings Displays recent content of default configuration file only and exits program. -d --display-settings <configfile> Displays recent content of configuration file referred to by <configfile> only and exit program.As you see you can use this option with an argument as well as without. This changes its meaning in detail. So I decided to split this into two help entries, in order not to confuse description by merging both into one statement, when it comes to more complex descriptions than this example. Think of what kind of sentence structure this would have been resulting in when more complex things are to be described. But possibly we should set together and rewrite these entries completely to sort out the purposeful duplicates by something like
-d --display-settings [<configfile>] Displays recent content of configuration file only and exits program. If omitting the argument <configfile>, the default configuration file will be used.This way we would have only one entry per option.
Please note: The line breaks and blanks are set only in German language version correctly, since I was quite sure my English translations (GB as well as US) are urgently in need of major overhauling by a native speaker. Hence it wouldn’t have made any sense to carefully balance the typeset by adding or removing blanks and/or moving line breaks in my rough translation. Refer to German source strings to get an idea how it might look like. There is no design directive, you can freely arrange it in translation, but just think of other “command -h” output you know from console.
…transifex tip. I did not know that!
They have hidden it very well, behind a meaningless menu entry, nobody would expect to be meant for actual change the setting.
So long.
RobinWindows is like a submarine. Open a window and serious problems will start.
-
AuthorPosts
- You must be logged in to reply to this topic.