localizing-shell-scripts-without bashisms, gettext or ...

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

localizing-shell-scripts-without bashisms, gettext or ...

#31 Post by L18L »

Thank you, let us continue here.
In another thread fero10n wrote:You guys are so computer-skilled, while all I can do is translate between five languages
Our computer skills are very different. Technosaurus is master of hacking... while I am just trying to walk in some of his foot steps :)
but you are also a software tester now :D (Willy nilly :wink: )

-----
Edited
pt_BR should work now
If you first translate just some messages for pt (not all)
then these should be preloaded when starting pt_BR
Confirm?
----
Once more edited

:oops:
If you do this then pt is killed.
Change script t12s line 234 from
mv ${T}/${x}/${app} ${T}/${this_LANG}/${app}_tmp
to
cp ${T}/${x}/${app} ${T}/${this_LANG}/${app}_tmp

That is: copy instead of move and pt will continue to live
And soon you will become a coder too :D

ferro10n
Posts: 106
Joined: Wed 15 Jun 2011, 20:18
Contact:

Re: localizing-shell-scripts-without bashisms, gettext or ...

#32 Post by ferro10n »

L18L wrote:you are also a software tester now :D
Yes, sir! 8)
L18L wrote: Edited
pt_BR should work now
If you first translate just some messages for pt (not all)
then these should be preloaded when starting pt_BR
Confirm?
----
Once more edited
If you do this then pt is killed.
Change script t12s line 234 from
mv ${T}/${x}/${app} ${T}/${this_LANG}/${app}_tmp
to
cp ${T}/${x}/${app} ${T}/${this_LANG}/${app}_tmp

That is: copy instead of move and pt will continue to live
And soon you will become a coder too :D
Done. Here are the results:

:arrow: Tested t12s with mentioned line modified.
:arrow: Translation was generated properly with no more question marks where special characters should be, for example 'n?o' instead of 'não'.
:!: The adding of a new translated line caused the whole list of translatable lines to repeat below, making the list longer than it actually is.
:!: At times I submitted a translation and then saw the line blank where the new translation should be, I had to Undo, Quit and start the script again to be able to submit the translation. Finally, as the bug continued, I had to edit the generated locale file to manually complete the translation process.

Generated translations:

Code: Select all

_M_10="AJUDA"
_M_11="Arquivo novo:"
_M_12="Arquivo novo ou .delta:"
_M_13="Arquivo velho:"
_M_14="por favor espere..."
_M_15="Por favor espere, procurando arquivo velho..."
_M_16="Desculpe não achous-se ${OLDFILENAME}. Terá de arrastá-lo manualmente na caixa ´Arquivo velho´"
_M_17="SUCESSO! ${SOURCEFILE_DELTA} gerado"
_M_18="SUCESSO! ${SOURCEFILE_NEW} gerado"
_M_19="O autor do Xdelta é Joshua MacDonald."
_M_20="Primeiro deve-se instalar o pacote ´xdelta´"
_M_21="Interface escrita por Barry Kauler. Licença GPL v2."
_M_22="O algoritmo Rsync, que inspirou o algoritmo delta central, deve-se a Andrew Tridgell e Paul Mackerras."
_M_23="Istas mudanças (deltas) são similares à saida do programa ´diff´ em que podem-se utilizar para armazenar e transmitir somente as mudanças entre arquivos. Porém, ao contrário do diff, a saida do Xdelta não é expressada em um formato legível pelos humanos (além disso Xdelta pode aplicar estes deltas a uma copia do arquivo original). Xdelta utiliza um rápido algoritmo linear e desenvolve-se bem tanto em arquivos binários quanto em arquivos de texto."
_M_24="Para criar um arquivo ´.delta´, você precisa dois arquivos originais, um arquivo ´velho´ e um ´novo´. O arquivo delta gerado terá uma extensão ´.delta´."
_M_25="Para gerar um arquivo ´.delta´, arraste os arquivos velho e novo aqui, ou para recriar o arquivo novo arraste os arquivos velho e ´.delta´ aqui"
_M_26="Bemvindo/a, ista é uma interface para a ferramenta ´xdelta´, para administrar mudanças entre dois arquivos"
_M_27="Xdelta é um programa de aplicação desenhado para computar mudanças entre dois arquivos."
_M_28="Você pode recriar o arquivo ´novo´ original, enquanto você tenha o arquivo ´velho´ original e o arquivo ´.delta´. Este frontend de interface faz com que isto seja fácil: somente arraste o arquivo .delta na caixa, e o programa procurará e localizará o arquivo velho original. Ou, somente clique em um arquivo .delta em uma janela do ROX-Filer para re-gerar o arquivo novo original."
_M_3="Erro, ´Arquivo novo´ não existe"
_M_4="Erro, ´Arquivo velho´ não existe"
_M_5="ERRO! falhiu a geração do arquivo .delta. Mensagem de erro:"
_M_6="ERRO! falhiu a recriação do arquivo novo. Mensagem de erro:"
_M_7="ERRO: ${SOURCEFILE} não existe"
_M_8="GERAR"
A beginner Puppy Linux user
Intel(R) Celeron(R) CPU 2.13GHz 512MB
LiveCD user

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: localizing-shell-scripts-without bashisms, gettext or ...

#33 Post by L18L »

ferro10n wrote: :!: The adding of a new translated line caused the whole list of translatable lines to repeat below, making the list longer than it actually is.
:!: At times I submitted a translation and then saw the line blank where the new translation should be, I had to Undo, Quit and start the script again to be able to submit the translation. Finally, as the bug continued, I had to edit the generated locale file to manually complete the translation process.
Thank you
fixed :)
Attachments
t12s.gz
bugfix version 0.4.3
Rename it to t12s (without .gz)
(13.09 KiB) Downloaded 478 times

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#34 Post by 01micko »

Hi L18L

First, great job :)

I have 3 queries before I embark on my first attempt. (later, answered myself, app link at bottom of post :) )

1) Does this method handle strings with a newline char? ( \n )

example:

Code: Select all

echo -en "Choices \n1. Firefox \n2. Seamonkey \n\nChoose 1 or 2 to download \n"
A: Yes

2) Can we use escaped quotes?

example:

Code: Select all

echo "get_mozilla_browser-0.1
Invoke with \"get_mozilla_browser\" and you are offered a choice of 
\"firefox\" or \"seamonkey\" latest stable browsers direct from mozilla 
in your default locale if it exists.(snip)"
A: Yes

3) Can we use variables inside a string?

example:

Code: Select all

echo "$PACKAGE en-US will be downloaded "
A; No
-

If the answer to any or all of these is "no" it isn't a problem as I can split up the strings.

TIA

EDIT: app here!
Last edited by 01micko on Thu 01 Dec 2011, 05:47, edited 1 time in total.
Puppy Linux Blog - contact me for access

ferro10n
Posts: 106
Joined: Wed 15 Jun 2011, 20:18
Contact:

#35 Post by ferro10n »

This time around the t12s script worked nicely :D
I've even been able to change language so that I can make a new locale for the same file just after I finished the one I've worked on previously. However, I had to check that the locale folders were in place -- as the 'locales' folder was empty, I had to create individual folders for the locales I usually make (es, pt_BR, it, fr) so that the translations were generated there. If there wasn't a folder for the locale I wanted to work with, upon selecting the script to translate I got an empty list with no lines to translate, so I quit, created the locale folders and started t12s again, then I just wrote the folder name (es, it, fr, etc.) and got the list of translatable lines.
I think I'm ready to learn how to make the scripts translatable myself :D . Who knows, maybe I can make a localized pupplet, something like 'Wary EPI (= Español-Português-Italiano, the languages with less pupplets available that are based on newer puppy versions)'
Last edited by ferro10n on Sun 18 Dec 2011, 19:29, edited 2 times in total.
A beginner Puppy Linux user
Intel(R) Celeron(R) CPU 2.13GHz 512MB
LiveCD user

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

localizing-shell-scripts-without bashisms, gettext or ...

#36 Post by L18L »

Hi 01micko,

thanks for answering the first two questions yourself :)
you wrote:...
3) Can we use variables inside a string?

example:

Code: Select all

echo "$PACKAGE en-US will be downloaded "
A; No
-

If the answer to any or all of these is "no" it isn't a problem as I can split up the strings.
...
Splitting strings is :evil:
RTFineM
Enabling translation of entire sentences, that is the purpose of eval_gettext.
The equivalent in t12s method is (your example):

Code: Select all

[ -f $LOCALES ] && . $LOCALES
echo ${_M_:-$PACKAGE en-US will be downloaded }
A: Yes :D

The last two days I was trying this method on playmusic:
nice experience, bugfixes

I will have to update the documentation (BTW did you klick the button ´Developer´ ?)
{VAR} is no more required, see your PACKAGE example.

I will have a look into your app tomorrow.

Cheers

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

localizing-shell-scripts-without bashisms, gettext or ...

#37 Post by L18L »

ferro10n wrote:This time around the t12s script worked nicely :D
I've even been able to change language so that I can make a new locale for the same file just after I finished the one I've worked on previously.
Glad to read this :)
ferro10n wrote:However, I had to check that the locale folders were in place -- as the 'locales' folder was empty, I had to create individual folders for the locales I usually make (es, pt_BR, it, fr) so that the translations were generated there. If there wasn't a folder for the locale I wanted to work with, upon selecting the script to translate I got an empty list with no lines to translate, so I quit, created the locale folders and started t12s again, then I just wrote the folder name (es, it, fr, etc.) and got the list of translatable lines.
Sorry, but I cannot reproduce this. When I choose ar (Arabic, just an example :) ) then immediately the folder ar is automatically made in /usr/share/locales
ferro10n wrote:I think I'm ready to learn how to make the scripts translatable myself :D . Who knows, maybe I can make a localized pupplet, something like 'Wary EPI (= Español-Português-Italiano, the languages with less pupplets available that are based on newer puppy versions)'
Nice idea,
not
Español OR Português OR Italiano
but
Español AND Português AND Italiano QLS(QuickLanguageSwitcher) 8) no joke

-----------------------------------
Attached version 0.4.4 enables use of [ ] in message (result of my trial with pmusic)
Attachments
t12s.gz
rename to t12s (without .gz)
copy into /usr/sbin
requires yad
(14.06 KiB) Downloaded 449 times

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#38 Post by 01micko »

Please don't misunderstand, I didn't use the t12s prog, I did it manually.

I realise my syntax is wrong, which I'll fix and then try t12s.

Cheers
Puppy Linux Blog - contact me for access

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

localizing-shell-scripts-without bashisms, gettext or ...

#39 Post by L18L »

01micko wrote:Please don't misunderstand, I didn't use the t12s prog, I did it manually.

I realise my syntax is wrong, which I'll fix and then try t12s.

Cheers
OK, I did misunderstand :oops:

Start script t12s from command line line please.

The idea for this script was coming from practical use of the method:
Making IDs manually is ...
Repeated message (ex: please wait...) can be overseen
Numeric ID are shortest
The problem was to display the messages (including $...) in yad.
Every new app had new requirements to improve the code.

@ferro10n,
Maybe starting from command line can solve your problem?

@01micko,
your ´Browser Installer2´ appears to be a nice little app for demonstration. I would like to take screenshots from it and put them into my docu of t12s :)
apps I have converted to t12s
askpass
alsawizard
xdelta_gui
playmusic
None of these is good for public understanding (I will have to review them checking syntax...) but´Browser Installer2´ is an app everybody will understand.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#40 Post by 01micko »

L18L wrote:OK, I did misunderstand :oops:
..and ok too I did mislead :oops:
L18L wrote:@01micko,
your ´Browser Installer2´ appears to be a nice little app for demonstration. I would like to take screenshots from it and put them into my docu of t12s :)
8)

By all means. I deliberately kept it as simple as possible, partly with this in mind.

Later, (in a week maybe) I'll have some more time to help, give feedback, dive in, etcetera. Your t12s has great potential I think.
Puppy Linux Blog - contact me for access

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

localizing-shell-scripts-without bashisms, gettext or ...

#41 Post by L18L »

Having played with some of 01micko´s scripts it is time for a new version 0.4.5 of t12s now.

You may use now single quotes and double quotes inside messages
There is no more need to change them to apostrophes.

Using brackets [ ] you must have space after [ and before ]

Have fun
Attachments
t12s.gz
rename to t12s
(15.79 KiB) Downloaded 676 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

localizing-shell-scripts-without bashisms, gettext or ...

#42 Post by L18L »

doc or tutorial updated

and bugfix version='0.4.5.1
bug was:
-automated translation invoked though not good (no UTF8)
-pseudo language xxx not working (see doc above)
Attachments
t12s.gz
(16 KiB) Downloaded 461 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

xdelta_gui

#43 Post by L18L »

@Barry,

Spanish and German translations for xdelta_gui attached

xmessage does not display UTF-8

Could you convert xmessages to pupdialog --msgbox please?
Attachments
xdelta_gui_locales.tar.gz
spanish and german for xdelta_gui
(2.29 KiB) Downloaded 476 times

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Re: xdelta_gui

#44 Post by rodin.s »

L18L wrote:
xmessage does not display UTF-8

Could you convert xmessages to pupdialog --msgbox please?
For Russian I used a link from xmessage to gxmessage.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: xdelta_gui

#45 Post by L18L »

rodin.s wrote:
L18L wrote:
xmessage does not display UTF-8

Could you convert xmessages to pupdialog --msgbox please?
For Russian I used a link from xmessage to gxmessage.
I prefer yad --text="message" --button="gtk-ok:0"

But it is PuppyMaster´s choice :)

-----
t12s problem with " reminds me of our triple backslash fights :wink:
and your way to rewrite gtkdialogs
DIALOG='.....'"....."'....'
instead of
DIALOG="...."..."...."
:)

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

automated translation

#46 Post by L18L »

Dutch people appear to have trained the bot better than the Germans :D

Crying HELP is ignored
Attachments
automated_translations.png
(58.23 KiB) Downloaded 1010 times

ferro10n
Posts: 106
Joined: Wed 15 Jun 2011, 20:18
Contact:

#47 Post by ferro10n »

ferro10n (me) wrote:I think I'm ready to learn how to make the scripts translatable myself
OK, I spoke too soon :oops:
I think I'll just keep testing until I get some experience
A beginner Puppy Linux user
Intel(R) Celeron(R) CPU 2.13GHz 512MB
LiveCD user

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

Re: automated translation

#48 Post by Bert »

L18L wrote:Dutch people appear to have trained the bot better than the Germans :D

Crying HELP is ignored
Did I hear the word "Dutch"? :wink:

Don't worry, the automated dutch translation is horrible.

Imagine a spoiled son of a rich lawyer, with lots of whisky and some royal blood running through his veins, who is about to spend the last bits of the family fortune on 'Wein, Weib und Gesang', trying to get up from his chair at the bar, with the intention to deliver an unforgettable speech..that's more or less how the G-translation sounds :roll:
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

Re: automated translation

#49 Post by technosaurus »

Bert wrote:
L18L wrote:Dutch people appear to have trained the bot better than the Germans :D

Crying HELP is ignored
Did I hear the word "Dutch"? :wink:

Don't worry, the automated dutch translation is horrible.

Imagine a spoiled son of a rich lawyer, with lots of whisky and some royal blood running through his veins, who is about to spend the last bits of the family fortune on 'Wein, Weib und Gesang', trying to get up from his chair at the bar, with the intention to deliver an unforgettable speech..that's more or less how the G-translation sounds :roll:
Sounds great, maybe we can translate it back to English for en_US.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

automated translation

#50 Post by L18L »

t12s version 0.4.6

After a time of being not connected to internet I have added automated translation now.

Note, I was a bit lazy converting, tested just ru ar el iw
line 376 ff:

Code: Select all

      # convert file to=utf-8
      case ${x} in
       de|fr|it|pt|nl|da|sv|no|fi) fromCHAR=ISO8859-1;;
       ru) fromCHAR=KOI-8;;
       ar) fromCHAR=ISO8859-6;;
       el) fromCHAR=ISO8859-7;;
       iw) fromCHAR=ISO8859-8;;
        *) fromCHAR=ISO8859-16;;
      esac 
      iconv -f $fromCHAR -t UTF-8 < ${T}/${x}/${app} >${T}/${x}/${app}_utf8
Translated names of variables should be restored now.
Messages which have more than 1 variable are excluded.

Happy New Year
Attachments
t12s.gz
rename to t12s
(19.68 KiB) Downloaded 561 times
t12s_rtl.png
xdelta_gui iw
(39.53 KiB) Downloaded 959 times

Post Reply