Page 2 of 4
Posted: Fri 18 Nov 2011, 10:51
by L18L
technosaurus wrote:I am posting from my Droid so the following syntax will be "off"
[ -f /.../$LANG/app ] && LOCALES=/.../$LANG/app ¦¦ [ -f /.../${LANG%%_*} ] && LOCALES=/.../${LANG%%_*}
. $LOCALES
Seen this before your "edit"
That is: your one-liner can replace my two-lines code for enabling "regional variants" of language.
And LOCALES replaces LANGPATH.
_____________
edited later
and LOCALE
S is avoiding need of M/ under LOCALE
_______________
Very nice. Thank you
Posted: Fri 18 Nov 2011, 11:20
by L18L
technosaurus wrote:...
replace trans.txt with your english file and tl=es with tl=??
where ?? is
...
g** wrote:
Sorry, the page you requested contains a file type (application/octet-stream) we are unable to translate.
my script wrote:#!/bin/sh
echo -n > ./t12s_g_de
curl -A
defaultbrowser \
-F "
file=/dev/shm/t12s_askpass_en;type=text/plain" \
-F "sl=en" \
-F "tl=
de" \
http://translate.googleusercontent.com/translate_f | while read A || [ "$A" ]; do
case $A in
"<meta"*)continue;;
*"<pre>"*)echo ${A##*"<pre>"}
>> ./t12s_g_de;;
*"</pre>"*)echo ${A%%"</pre>"*}
>> ./t12s_g_de;;
*)echo $A
>> ./t12s_g_de;;
esac
done
g has been my friend until this happened
http://murga-linux.com/puppy/viewtopic. ... 9&start=33
Anyhow nice idea
Posted: Fri 18 Nov 2011, 11:29
by technosaurus
Ok, I've merged them together to get autotranslated locale files but all my trial and error caused me to exceed the max queries temporarily. Can someone try this on a _M_ formatted script:
Code: Select all
#!/bin/bash
FROM=/C/
[ ! -d /usr/share/locales/C/ ] && mkdir /usr/share/locales/C/
for x in $@ ; do
TEMPLATE=/usr/share/locales/C/${x##*/}
while read -d$ A || [ "$A" ]; do
case "$A" in
*{_M_*)B=_M${A##*_M};B=${B%%\}*};echo ${B//:-/=};;
esac
done < $x >$TEMPLATE
for x in es yi cy sq ar hy az eu be bn bg ca zh-CN zh-TW hr cs da nl en et tl fi fr gl ka de el gu ht iw hi hu is id ga it ja kn ko la lv lt mk ms mt no fa pl pt ro ru sr sk sl es sw sv ta te th tr uk ur vi cy yi ; do
TO=/${x//-/_}/
[ ! -d ${TEMPLATE%%/C/*}/${x//-/_} ] && mkdir ${TEMPLATE%%/C/*}/${x//-/_}
curl -A firefox \
-F "file=@$TEMPLATE;type=text/plain" \
-F "sl=en" \
-F "tl=$x" \
http://translate.googleusercontent.com/translate_f | \
while read A || [ "$A" ]; do
case $A in
"<meta"*)A="";;
*"<pre>"*)A=${A##*"<pre>"};;
*"</pre>"*)A=${A%%"</pre>"*};;
esac
[ "$A" ] && echo ${A// = /=\"}\"
done > ${TEMPLATE//$FROM/$TO}
done
rm $TEMPLATE
done
Note: may need to have a .txt extension on the submitted file
Starting translation supported by g
Posted: Fri 18 Nov 2011, 13:39
by L18L
Success
technosaurus wrote:...
Note: may need to have a .txt extension on the submitted file
# TEMPLATE=/usr/share/locales/C/${x##*/}
TEMPLATE=/usr/share/locales/C/${x##*/}.txt
I have run it for 6 languages
time
real 0m8.659s
user 0m0.292s
sys 0m0.076s
Spanish:
_M_1="Esta aplicación necesita para funcionar:"
_M_2="La contraseña del administrador se requiere:"
_M_3="Por favor introduzca la contraseña de administrador para ejecutar esta aplicación:"
_M_4 Tipo="admin contraseña necesaria para ejecutar esta aplicación:"
_M_5 =... No"
ferro10n, este esta bueno?
As a start for a good translation, better than English!
Wondering where the
Tipo is coming from
Re: Starting translation supported by g
Posted: Fri 18 Nov 2011, 20:59
by ferro10n
L18L wrote:Success
technosaurus wrote:...
Note: may need to have a .txt extension on the submitted file
# TEMPLATE=/usr/share/locales/C/${x##*/}
TEMPLATE=/usr/share/locales/C/${x##*/}.txt
I have run it for 6 languages
time
real 0m8.659s
user 0m0.292s
sys 0m0.076s
Spanish:
_M_1="Esta aplicación necesita para funcionar:"
_M_2="La contraseña del administrador se requiere:"
_M_3="Por favor introduzca la contraseña de administrador para ejecutar esta aplicación:"
_M_4 Tipo="admin contraseña necesaria para ejecutar esta aplicación:"
_M_5 =... No"
ferro10n, este esta bueno?
As a start for a good translation, better than English!
Wondering where the
Tipo is coming from
This is from Google Translate, isn't it?
Well, here's what the lines are supposed to be in Spanish:
Code: Select all
_M_1="Esta aplicación quiere ejecutar:"
_M_2="Requiere contraseña de administrador:"
_M_3="Por favor introduzca la contraseña de administrador requerida para ejecutar esta aplicación:"
_M_4="Escribir contraseña de administrador requerida para ejecutar esta aplicación:"
_M_5="... Falló"
The 'Tipo' comes from 'Type', I think, which in that line should be 'escribir'. We don't have a special word for 'to write by keyboard' in Spanish, although there are heretic people who translate it as 'tipear'.
Posted: Sat 19 Nov 2011, 01:26
by technosaurus
Noone expects Google to get all the translating 100%, but at least its better than 0%.
Note that I use the Google translate site directly masked as FireFox with curl (wget cannot do right metadata for files), since the translate api is deprecated... So as long as the site itself is fairly stable, it should continue to work.
Posted: Sat 19 Nov 2011, 01:35
by ferro10n
technosaurus wrote:Noone expects Google to get all the translating 100%, but at least its better than 0%.
Note that I use the Google translate site directly masked as FireFox with curl (wget cannot do right metadata for files), since the translate api is deprecated... So as long as the site itself is fairly stable, it should continue to work.
Sorry, I didn't read the full posts
You're right, the translations may not be the most accurate, but they're understandable. As you said, it's better than 0%. You should make a PET
Posted: Sat 19 Nov 2011, 02:39
by technosaurus
Now if I can just figure out how to connect piece G to happy.
I havent ironed out or commented on possible oopses or known issues ... For instance it won't work on translation variables that contain variables due to using $ as a separator... ${_M_1:-$hello world} would break the translation
... Still needs a bit of testing and documentation before people go installing it Willy nilly from a pet without looking at the code.
oopses
Posted: Sat 19 Nov 2011, 10:55
by L18L
@ferro10n,
please forget what I have announced about another version (enabling pt_BR) for now. There is enough other stuff to be done before next version.
http://www.phrases.org.uk/meanings/willy-nilly.html ________________
technosaurus wrote:Now if I can just figure out how to connect piece G to happy.
I havent ironed out or commented on possible oopses or known issues ... For instance it won't work on translation variables that contain variables due to using $ as a separator... ${_M_1:-$hello world} would break the translation
... Still needs a bit of testing and documentation before people go installing it Willy nilly from a pet without looking at the code.
Known issue:
- wrong placement in variable
name
_M_4
Tipo="admin contraseña necesaria para ejecutar esta aplicación:"
- other languages:
--Greek
_M_5 =...
Posted: Mon 28 Nov 2011, 04:35
by ferro10n
localizing-shell-scripts-without bashisms, gettext or ...
Posted: Mon 28 Nov 2011, 11:54
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
(Willy nilly
)
-----
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
Re: localizing-shell-scripts-without bashisms, gettext or ...
Posted: Tue 29 Nov 2011, 04:08
by ferro10n
L18L wrote:you are also a software
tester now
Yes, sir!
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
Done. Here are the results:
Tested t12s with mentioned line modified.
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"
Re: localizing-shell-scripts-without bashisms, gettext or ...
Posted: Tue 29 Nov 2011, 18:29
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
Posted: Wed 30 Nov 2011, 20:36
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!
Posted: Thu 01 Dec 2011, 04:22
by ferro10n
This time around the t12s script worked nicely
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
. 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)'
localizing-shell-scripts-without bashisms, gettext or ...
Posted: Thu 01 Dec 2011, 20:11
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
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
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
localizing-shell-scripts-without bashisms, gettext or ...
Posted: Thu 01 Dec 2011, 20:39
by L18L
ferro10n wrote:This time around the t12s script worked nicely
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
. 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)
no joke
-----------------------------------
Attached version 0.4.4 enables use of [ ] in message (result of my trial with pmusic)
Posted: Fri 02 Dec 2011, 00:11
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
localizing-shell-scripts-without bashisms, gettext or ...
Posted: Fri 02 Dec 2011, 09:41
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
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.
Posted: Fri 02 Dec 2011, 13:21
by 01micko
L18L wrote:OK, I did misunderstand
..and ok too I did mislead
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
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.