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, 01:38
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
zigbert


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

PostPosted: Mon 30 Jul 2012, 08:35    Post subject:  

L18L
Waiting for response of Barry before updating pProcess to benefit of your MoManager improvements.


Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 3359
Location: Ontario

PostPosted: Mon 30 Jul 2012, 18:00    Post subject:  

Puppy backup which is an improved clone of pmirror
is finished.

Pmirror can and should be forgotten.

Localized with Zigbert's method.
Yaf-splash is now used to indicate activity.

I've gone as far as I can with this one. Laughing

http://murga-linux.com/puppy/viewtopic.php?t=77685

_____________________________________________________
Back to top
View user's profile Send private message 
shinobar


Joined: 28 May 2009
Posts: 2631
Location: Japan

PostPosted: Mon 30 Jul 2012, 19:21    Post subject: Re: zigbert and gettext  

zigbert wrote:
If someone out there wants to help out converting apps to use gettext (like L18L did for pClock), that is no problem to fix. The only thing we need to keep track of is that you work on the latest code.

Great.
I guess we can convert your localization to gettext automatically. It will ensure the code always to be the latest.

_________________
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: 2541
Location: Moved from Hosla to www.eussenheim.de

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   675 Time(s)

pfilesearch.png

pfilesearch-1.31.pet
Description  for testing only
pet

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


Joined: 28 May 2009
Posts: 2631
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: 2541
Location: Moved from Hosla to www.eussenheim.de

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: 2631
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  374 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: 2541
Location: Moved from Hosla to www.eussenheim.de

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: 2631
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: 2631
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: 2541
Location: Moved from Hosla to www.eussenheim.de

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: 2631
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: 5760
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: 2541
Location: Moved from Hosla to www.eussenheim.de

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   510 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  373 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  360 Time(s) 
Back to top
View user's profile Send private message 
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.1129s ][ Queries: 13 (0.0127s) ][ GZIP on ]