| Author |
Message |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Tue 31 Jul 2012, 16:21 Post subject:
Re: zigbert and gettext Subject description: converting simple things first |
|
| zigbert wrote: | | L18L wrote: | | I am going to try converting Pfilesearch now. | Great. Version 1.30 is up to date |
It has been not so simple.
gettext does not like messages starting with - (minus)
so I had to change the text, see picture
But using the new momanager_enhanced was fun.
I have made 1.31.pet ( containing de also )
| Code: | # ./pfilesearch -h
Optionen
-b als backend benutzen. Keine Suchergebnisse anzeigen
-bb Nicht 'Keine Dateien gefunden!' anzeigen
-bbb Nicht 'Suche...' anzeigen
-c [STRING] Stumme Suche. Kein GUI
-d [DIR] In einem spezifischen Ordner suchen
-e Embedded laufen - gtkdialog code is pointed to stdout
-ee Embedded laufen - Optionen überspringen
-f [FILTER] Nur durchsuchen nach Dateigruppen:
documents Dokumente
pictures Bilder
music Musik
videos Videos
emails E-Mails
compressed_files Komprimierte Dateien
code_files Code-Dateien
-i Konfigurationsdateien installieren und beenden
-h Diese Hilfe anzeigen
-p Einstellungen GUI bei Start anzeigen
-t [STRING] Standard-Suchtext definieren
-v Version von Pfilesearch anzeigen
# |
| Description |
|
| Filesize |
40.57 KB |
| Viewed |
528 Time(s) |

|
| Description |
for testing only
|

Download |
| Filename |
pfilesearch-1.31.pet |
| Filesize |
11.99 KB |
| Downloaded |
200 Time(s) |
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2253 Location: Japan
|
Posted: Tue 31 Jul 2012, 18:39 Post subject:
Re: zigbert and gettext -automate Subject description: converting simple things first |
|
| L18L wrote: | It has been not so simple.
gettext does not like messages starting with - (minus)
so I had to change the text, |
Yeh.
I have tried automatic conversion by next code against the locales file:
| Code: | | sed -e 's/\([^=\]\)"\([ ]*#.*$\)/\1")\2/' -e 's/\([^=\]\)"[ ]*$/\1")/' -e 's/^\([A-Z][0-9A-Z_]*\)="/\1=$(gettext "/' -e "s/\\([^=\\]\\)'\\([ ]*#.*\$\\)/\\1')\\2/" -e "s/\\([^=\\]\\)'[ ]*\$/\\1')/" -e "s/^\\([A-Z][0-9A-Z_]*\\)='/\\1=\$(gettext '/" $SOURCE > $DEST |
Mostly it works. But some case, we need to modify the original...
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Wed 01 Aug 2012, 15:27 Post subject:
Re: zigbert and gettext -automate Subject description: converting simple things first |
|
| shinobar wrote: | | Mostly it works. But some case, we need to modify the original... |
I have tested it with SOURCE=/usr/local/pfilesearch/locales
Does convert half (just the trailing ) ) for
export ....
and more than 1 liners
Examples:
export LOC_NO="No")
LOC_QUIT=$(gettext "Quit")
Missing
'$(gettext '
can easily be inserted manually.
------
Converting also the existing translations would be great
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2253 Location: Japan
|
Posted: Wed 01 Aug 2012, 23:22 Post subject:
locale2gettext v0.1 |
|
Full automation is difficult. But it will hopefully be an useful tool.
Unzip the attached, add executable, place at /root/applications/bin or somewhere under the $PATH.
# locale2gettext --help
locale2gettext 0.1
Convert locales of zigbert into gettext version.
usage: locale2gettext [PATH_TO_LOCALE_FILE] [TEXT_DOMAIN]
| Description |
Unzip, add executable, place at /root/applications/bin
|

Download |
| Filename |
locale2gettext.gz |
| Filesize |
1.11 KB |
| Downloaded |
209 Time(s) |
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Thu 02 Aug 2012, 08:52 Post subject:
Re: locale2gettext v0.1 |
|
| shinobar wrote: | | Full automation is difficult. But it will hopefully be an useful tool. |
Yes it is helpful, has been running successfully for pfilesearch
I have tried to put the gettext into the script
(easier to understand and to maintain)
Does not work with multi line messages
But I got pfilesearch running with this:
| Code: |
#!/bin/sh
# replace variables by gettext expression
# example:
# LOC_OPTIONS=$(gettext "Options") # line in locales.converted
# line in script:
# <frame $LOC_OPTIONS>
# will become:
# <frame $(gettext "Options")>
#
input_file=locales.converted
# create sed file
conversion_file=locales.sed
delimiter='@' # not used in script ???
echo "#sed expressions for conversion of pfilesearch" > $conversion_file
while read LINE; do
case "$LINE" in
\#*) continue # skip comments
;;
*) [ -z "$LINE" ] && continue # skip blank lines
[ "`echo $LINE | grep '^export TEXTDOMAIN='`" ] && continue # skip
[ "`echo $LINE | grep '^export OUTPUT_CHARSET='`" ] && continue # skip
[ "${LINE:0:7}" = "export " ] && LINE="${LINE//export }" # delete 'export '
LINE="${LINE//=\$\(/$delimiter\$(}" # s#FROM${delimiter}TO#
[ "${LINE:0:3}" = "LOC" ] && LINE="s${delimiter}${LINE//\$}" # s${delimiter}FROM#TO#
[ "`echo $LINE | grep -E '\"\)$'`" ] && LINE="${LINE}${delimiter}" # s#FROM$#TO${delimiter}
;;
esac
echo $LINE >> $conversion_file
done < $input_file
echo finished $conversion_file
# delete multiliners
cat $conversion_file | grep -E "^s${delimiter}LOC" | grep -E "${delimiter}$" > $conversion_file.1liners
echo finished $conversion_file.1liners
# replace $LOCxxx by gettext (....)
sed -f $conversion_file.1liners pfilesearch > pfilesearch.converted
echo finished pfilesearch.converted
chmod +x pfilesearch.converted
echo run converted script in console to see errors !
echo some errors can be fixed by escaping quotes !!
echo do not forget to the muliliners !!! |
Feel free to add it (maybe change some variables) to your locale2gettext
I am going to convert pfind now. That is the most logical step after pfilesearch.
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2253 Location: Japan
|
Posted: Thu 02 Aug 2012, 09:04 Post subject:
replace variables by gettext expression |
|
| L18L wrote: | # replace variables by gettext expression
# example:
# LOC_OPTIONS=$(gettext "Options") # line in locales.converted
# line in script:
# <frame $LOC_OPTIONS>
# will become:
# <frame $(gettext "Options")> |
Why we need it?
| L18L wrote: | | (easier to understand and to maintain) |
I am not sure.
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2253 Location: Japan
|
Posted: Thu 02 Aug 2012, 09:13 Post subject:
Re: replace variables by gettext expression |
|
If we convert only the file 'locales' and do not change any of others, it allows backward compatibility, i mean we can use old NLS as is.
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Thu 02 Aug 2012, 09:33 Post subject:
Re: replace variables by gettext expression |
|
| shinobar wrote: | | If we convert only the file 'locales' and do not change any of others, it allows backward compatibility, i mean we can use old NLS as is. |
yeah, that is true.
But new apps should be coded without the LOCxx variables
It is easier to use just gettext inside the script.
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2253 Location: Japan
|
Posted: Thu 02 Aug 2012, 19:26 Post subject:
Re: replace variables by gettext expression |
|
| shinobar wrote: | | If we convert only the file 'locales' and do not change any of others, it allows backward compatibility, i mean we can use old NLS as is. |
But it is not a good idea...
The script takes the older NLS if there are both old and new.
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
|
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 5241 Location: Valåmoen, Norway
|
Posted: Fri 03 Aug 2012, 02:54 Post subject:
|
|
| L18L wrote: | | I am going to convert pfind now. That is the most logical step after pfilesearch. | Great!!!
| shinobar wrote: | | If we convert only the file 'locales' and do not change any of others, it allows backward compatibility, i mean we can use old NLS as is. | Gettext has the advantage of making the code more readable (also for me ). That is a good thing for the community. Converting the locales-file would sure be good for backward compatibility, but for moving the project further, I think updating the code itself is the way to go.
Sigmund
_________________ Stardust resources
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Fri 03 Aug 2012, 15:57 Post subject:
|
|
| zigbert wrote: | | updating the code itself is the way to go. |
There is always something to learn and something to improve.
Generating po files from the old locals is also possible.
| Code: | # LOC200
msgid "Filename"
msgstr "Имя файла"
# LOC203
msgid "Last modified"
msgstr "Изменен"
# LOC204
msgid "Permissions"
msgstr "Разрешения"
# LOC205
msgid "User"
msgstr "Пользователь" |
Wait and see
| Description |
LANGUAGE=auto:ru:de |
| Filesize |
35.79 KB |
| Viewed |
369 Time(s) |

|
|
|
Back to top
|
|
 |
rodin.s
Joined: 22 Sep 2010 Posts: 323 Location: Ukraine
|
Posted: Fri 03 Aug 2012, 17:35 Post subject:
Gettext in pBurn. Subject description: Not tested well. |
|
I have added gettext to pBurn but haven't tested it well yet. Just tested main GUI and have made partial Russian translation for testing. I haven't change set-language section of pburn script so translation only works if I choose or type in 'ru' language in Preferences.
I also didn't know what to do with line 398 of func_gui_options.
New MoManager finds all files and creates proper pot-file.
I didn't internationalize file func_man since it didn't have '$LOC' before...
| Description |
Pburn with gettext. Not tested. Some mistakes possible.
|

Download |
| Filename |
pburn_gtxt-3.7.3.pet |
| Filesize |
71.67 KB |
| Downloaded |
207 Time(s) |
| Description |
partial Russian translation just for testing ... I will update it soon.
|

Download |
| Filename |
MoManager-ru_UA-pburn-3.7.3.tar.gz |
| Filesize |
3.69 KB |
| Downloaded |
198 Time(s) |
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Sat 04 Aug 2012, 14:24 Post subject:
pfind Subject description: alpha |
|
Please test version 5.02
NLS has German (of course) and Russian (converted from old system)
So you can change between de, ru and English
Next I will try to convert the other languages.......
| Description |
|
| Filesize |
7.97 KB |
| Viewed |
590 Time(s) |

|
| Description |
Russian (to be completed) and German
|

Download |
| Filename |
pfind-NLS.pet |
| Filesize |
8.45 KB |
| Downloaded |
208 Time(s) |
| Description |
|

Download |
| Filename |
pfind-5.02.pet |
| Filesize |
18.72 KB |
| Downloaded |
213 Time(s) |
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1715 Location: Burghaslach, Germany
|
Posted: Sat 04 Aug 2012, 14:35 Post subject:
Re: Gettext in pBurn. Subject description: Not tested well. |
|
| rodin.s wrote: | | ...I haven't change set-language section of pburn script so translation only works if I choose or type in 'ru' language in Preferences.... |
Hope you understand my solution in pfind ( used it in ymount some time ago ) Search for LANGUAGE NEW_LANGUAGE and LANGUAGES
Sorry I cannot help very much with testing because I do NOT have CD burner
|
|
Back to top
|
|
 |
shinobar

Joined: 28 May 2009 Posts: 2253 Location: Japan
|
Posted: Sun 05 Aug 2012, 07:05 Post subject:
zigbert2gettext-0.1 |
|
| zigbert wrote: | Gettext has the advantage of making the code more readable (also for me ). That is a good thing for the community. Converting the locales-file would sure be good for backward compatibility, but for moving the project further, I think updating the code itself is the way to go. |
OK, the first trial to place gettext inline the code.
But for multiple lines, i think we are better to stay the substitution method, that is:
| Code: | export LOCXXX=$(gettext "First line
Second lne")
export DIALOG="<text><input>echo -n \"\$LOCXXX\"</inout></text>" |
Extract the attached, add executable, place it at /root/my-applications/bin.
# zigbert2gettext --help
zigbert2gettext 0.1
Convert zigbert apps into gettext version.
usage: zigbert2gettext [PATH_TO_MAIN_SCRIPT] [TEXT_DOMAIN]
PATH_TO_MAIN_SCRIPT - example: /usr/local/pburn/pburn
But still you need to remove manually some code, loading the locales file, from the converted main script.
| Description |
Unzip, add executable, place at /root/my-applications/bin.
|

Download |
| Filename |
zigbert2gettext.gz |
| Filesize |
2.3 KB |
| Downloaded |
236 Time(s) |
_________________ Multilingual Wary-511
Lucid Puppy Quickset edition
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
|
|
Back to top
|
|
 |
|