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 Wed 03 Sep 2014, 03:32
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects » Localization Project
zigbert and gettext
Moderators: Lobster, MU, raffy
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 5 [72 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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. Very Happy

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
#
pfilesearch.png
 Description   
 Filesize   40.57 KB
 Viewed   637 Time(s)

pfilesearch.png

pfilesearch-1.31.pet
Description  for testing only
pet

 Download 
Filename  pfilesearch-1.31.pet 
Filesize  11.99 KB 
Downloaded  357 Time(s) 
Back to top
View user's profile Send private message 
shinobar


Joined: 28 May 2009
Posts: 2618
Location: Japan

PostPosted: 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...

_________________
Google Chrome portable
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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 Question
Back to top
View user's profile Send private message 
shinobar


Joined: 28 May 2009
Posts: 2618
Location: Japan

PostPosted: 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]
locale2gettext.gz
Description  Unzip, add executable, place at /root/applications/bin
gz

 Download 
Filename  locale2gettext.gz 
Filesize  1.11 KB 
Downloaded  360 Time(s) 

_________________
Google Chrome portable
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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
View user's profile Send private message 
shinobar


Joined: 28 May 2009
Posts: 2618
Location: Japan

PostPosted: 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.

_________________
Google Chrome portable
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Back to top
View user's profile Send private message Visit poster's website 
shinobar


Joined: 28 May 2009
Posts: 2618
Location: Japan

PostPosted: 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.
_________________
Google Chrome portable
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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
View user's profile Send private message 
shinobar


Joined: 28 May 2009
Posts: 2618
Location: Japan

PostPosted: 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.

_________________
Google Chrome portable
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5701
Location: Valåmoen, Norway

PostPosted: 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 Very Happy ). 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
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Fri 03 Aug 2012, 15:57    Post subject:  

zigbert wrote:
updating the code itself is the way to go.

Smile
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 Cool
pfind_semi_ru.png
 Description   LANGUAGE=auto:ru:de
 Filesize   35.79 KB
 Viewed   475 Time(s)

pfind_semi_ru.png

Back to top
View user's profile Send private message 
rodin.s

Joined: 22 Sep 2010
Posts: 338
Location: Ukraine

PostPosted: 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...
pburn_gtxt-3.7.3.pet
Description  Pburn with gettext. Not tested. Some mistakes possible.
pet

 Download 
Filename  pburn_gtxt-3.7.3.pet 
Filesize  71.67 KB 
Downloaded  361 Time(s) 
MoManager-ru_UA-pburn-3.7.3.tar.gz
Description  partial Russian translation just for testing ... I will update it soon.
gz

 Download 
Filename  MoManager-ru_UA-pburn-3.7.3.tar.gz 
Filesize  3.69 KB 
Downloaded  350 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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.......
pfind_changeLANGUAGE.png
 Description   
 Filesize   7.97 KB
 Viewed   691 Time(s)

pfind_changeLANGUAGE.png

pfind-NLS.pet
Description  Russian (to be completed) and German
pet

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

 Download 
Filename  pfind-5.02.pet 
Filesize  18.72 KB 
Downloaded  361 Time(s) 
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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 Laughing ) 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
View user's profile Send private message 
shinobar


Joined: 28 May 2009
Posts: 2618
Location: Japan

PostPosted: 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 Very Happy ). 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.
zigbert2gettext.gz
Description  Unzip, add executable, place at /root/my-applications/bin.
gz

 Download 
Filename  zigbert2gettext.gz 
Filesize  2.3 KB 
Downloaded  384 Time(s) 

_________________
Google Chrome portable
Downloads for Puppy Linux http://shino.pos.to/linux/downloads.html
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 5 [72 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 » Puppy Projects » Localization Project
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.1066s ][ Queries: 12 (0.0067s) ][ GZIP on ]