Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 01 Nov 2014, 00:47
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
localizing-shell-scripts-without bashisms, gettext or ...
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 5 [63 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Mon 28 Nov 2011, 07:54    Post subject: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: back from puppylinux.info
 

ferro10n wrote:
Posted about my last test in the Puppy Linux Help site.

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 Smile
but you are also a software tester now Very Happy (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

Embarassed
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 Very Happy
Back to top
View user's profile Send private message 
ferro10n

Joined: 15 Jun 2011
Posts: 106

PostPosted: Tue 29 Nov 2011, 00:08    Post subject: Re: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: back from puppylinux.info
 

L18L wrote:
you are also a software tester now Very Happy


Yes, sir! Cool

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 Very Happy


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'.
Exclamation 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.
Exclamation 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:

_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"
xdelta-pt_BR-locale-strings-repeat-to-infinite-each-time-new-translation-is-added.png
Description 
png

 Download 
Filename  xdelta-pt_BR-locale-strings-repeat-to-infinite-each-time-new-translation-is-added.png 
Filesize  227.72 KB 
Downloaded  238 Time(s) 
xdelta-pt_BR-locale-test-t12s.png
Description 
png

 Download 
Filename  xdelta-pt_BR-locale-test-t12s.png 
Filesize  254.99 KB 
Downloaded  222 Time(s) 

_________________
A beginner Puppy Linux user
Intel(R) Celeron(R) CPU 2.13GHz 512MB
LiveCD user
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Tue 29 Nov 2011, 14:29    Post subject: Re: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: bugfix version 0.4.3
 

ferro10n wrote:

Exclamation 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.
Exclamation 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 Smile
t12s.gz
Description  bugfix version 0.4.3
Rename it to t12s (without .gz)
gz

 Download 
Filename  t12s.gz 
Filesize  13.09 KB 
Downloaded  240 Time(s) 
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7841
Location: qld

PostPosted: Wed 30 Nov 2011, 16:36    Post subject:  

Hi L18L

First, great job Smile

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

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

example:
Code:
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:
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:
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!

_________________
Woof Mailing List | keep the faith Cool |

Last edited by 01micko on Thu 01 Dec 2011, 01:47; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
ferro10n

Joined: 15 Jun 2011
Posts: 106

PostPosted: Thu 01 Dec 2011, 00:22    Post subject:  

This time around the t12s script worked nicely Very Happy
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 Very Happy . 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)'

_________________
A beginner Puppy Linux user
Intel(R) Celeron(R) CPU 2.13GHz 512MB
LiveCD user

Last edited by ferro10n on Sun 18 Dec 2011, 15:29; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Thu 01 Dec 2011, 16:11    Post subject: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: A 3
 

Hi 01micko,

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

example:
Code:
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 or Very Mad
RTFineM
Enabling translation of entire sentences, that is the purpose of eval_gettext.
The equivalent in t12s method is (your example):

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


A: Yes Very Happy

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
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Thu 01 Dec 2011, 16:39    Post subject: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: locales folder
 

ferro10n wrote:
This time around the t12s script worked nicely Very Happy
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 Smile

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 Smile ) 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 Very Happy . 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) Cool no joke

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

 Download 
Filename  t12s.gz 
Filesize  14.06 KB 
Downloaded  227 Time(s) 
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7841
Location: qld

PostPosted: Thu 01 Dec 2011, 20:11    Post subject:  

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

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 02 Dec 2011, 05:41    Post subject: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: t12s
 

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 Embarassed

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 Smile
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.
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7841
Location: qld

PostPosted: Fri 02 Dec 2011, 09:21    Post subject:  

L18L wrote:
OK, I did misunderstand Embarassed
..and ok too I did mislead Embarassed
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 Smile
Cool

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.

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Fri 09 Dec 2011, 14:43    Post subject: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: new version of t12s
 

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
t12s.gz
Description  rename to t12s
gz

 Download 
Filename  t12s.gz 
Filesize  15.79 KB 
Downloaded  267 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sat 10 Dec 2011, 17:42    Post subject: localizing-shell-scripts-without bashisms, gettext or ...
Subject description: doc
 

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)
t12s.gz
Description 
gz

 Download 
Filename  t12s.gz 
Filesize  16 KB 
Downloaded  235 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sun 11 Dec 2011, 15:25    Post subject: xdelta_gui
Subject description: xmessage and 2 translations
 

@Barry,

Spanish and German translations for xdelta_gui attached

xmessage does not display UTF-8

Could you convert xmessages to pupdialog --msgbox please?
xdelta_gui_locales.tar.gz
Description  spanish and german for xdelta_gui
gz

 Download 
Filename  xdelta_gui_locales.tar.gz 
Filesize  2.29 KB 
Downloaded  235 Time(s) 
Back to top
View user's profile Send private message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: Sun 11 Dec 2011, 15:36    Post subject: Re: xdelta_gui
Subject description: xmessage and 2 translations
 

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.
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2541
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Sun 11 Dec 2011, 15:56    Post subject: Re: xdelta_gui
Subject description: xmessage and 2 translations
 

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 Smile

-----
t12s problem with \" reminds me of our triple backslash fights Wink
and your way to rewrite gtkdialogs
DIALOG='.....'"....."'....'
instead of
DIALOG="....\"...\"...."
Smile
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 3 of 5 [63 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1175s ][ Queries: 12 (0.0055s) ][ GZIP on ]