zigbert and gettext

For efforts in internationalising Puppy and solving problems in this area
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

pfind

#31 Post by L18L »

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.......
Attachments
pfind_changeLANGUAGE.png
(7.97 KiB) Downloaded 814 times
pfind-NLS.pet
Russian (to be completed) and German
(8.45 KiB) Downloaded 656 times
pfind-5.02.pet
(18.72 KiB) Downloaded 696 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Gettext in pBurn.

#32 Post by L18L »

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 :lol: ) Search for LANGUAGE NEW_LANGUAGE and LANGUAGES

Sorry I cannot help very much with testing because I do NOT have CD burner

User avatar
shinobar
Posts: 2672
Joined: Thu 28 May 2009, 09:26
Location: Japan
Contact:

zigbert2gettext-0.1

#33 Post by shinobar »

zigbert wrote:Gettext has the advantage of making the code more readable (also for me :D ). 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: Select all

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.
Attachments
zigbert2gettext.gz
Unzip, add executable, place at /root/my-applications/bin.
(2.3 KiB) Downloaded 691 times
Downloads for Puppy Linux [url]http://shino.pos.to/linux/downloads.html[/url]

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#34 Post by zigbert »

Hi guys
I am a bit out of time for Puppy right now.
I will try to catch up within a few days.


Thank you all for your effort to push Puppy forward.
Sigmund

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

pBurn updated

#35 Post by rodin.s »

I did some tests on pBurn. Tried to burn CD-R. Seems OK. I have also completed translation of mo-file: just have copied lines from old locale file in Poedit with some modifications.
I have also made some changes to previous pet: commented out set-locale this time.
I changed some translation lines for example:
Blank Disc - To blank the disc
and
Blank Disc - The disc is blank
have different translation so I have added whitespace to 'Blank Disc ' in func.
Same with 'Burn ISO-image' button in GUI: to burn and the burn have different translations.
Attachments
pburn_gtxt2-3.7.3.pet
Updated pBurn
(71.7 KiB) Downloaded 609 times
MoManager-ru_UA-pburn-3.7.3.tar.gz
Full Russian translation this time.
(14.14 KiB) Downloaded 599 times

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

ptiming

#36 Post by L18L »

L18L wrote:...Next I will try to convert the other languages.......
done
using shinobar's locale2gettext in

Code: Select all

#!/bin/sh
#
# convert translation file "Zigbert" to "Gettext"
# convert /usr/local/app/locals/LANG to /usr/share/locale/language/app.mo
#   which then can be checked/modified using momanager
# 20120805 by L18L

apps="`find /usr/local -name locals | cut -d'/' -f4`" # pburn pfind pfilesearch ... 
apps="ptiming" # no, just pvd for now

for app in $apps; do
 [ "$app" = "pfind" ] && continue
 [ "$app" = "pfilesearch" ] && continue
 SOURCE=/usr/local/$app/locales
 [ -f "$SOURCE" ]  ||  SOURCE=/usr/local/$app/locals/en_US:english
 [ -f "$SOURCE" ]  ||  continue                   # nothing to translate here
 echo " converting /usr/local/$app ..."

 # locale2gettext usage: $APPNAME [PATH_TO_LOCALE_FILE] [TEXT_DOMAIN]" 
 [ -f "$SOURCE.converted" ] || locale2gettext $SOURCE
 # $SOURCE.converted has LOCxxx=$(gettext "bla bla")
  
 langs=`ls /usr/local/$app/locals | cut -d'_' -f1 | sort -u`
 for lang in $langs; do # for each language
  [ "$lang" = "en" ] && continue
  echo "       from /usr/local/$app/locals/$lang ..."
  # input
  TEMPLfile=$SOURCE.converted
  # we know just ru and must say ru_RU
  LOCfile=`ls /usr/local/$app/locals/$lang* | head -n1`
  # output
  LOCfilePO=$LOCfile.po
 
echo '#, fuzzy
msgid ""
msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
' > $LOCfilePO

  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
        [ "`echo $LINE | grep '^set'`" ]                   && continue     # skip
        [ "${LINE:0:7}" = "export " ] && LINE="${LINE//export }"           # delete 'export '
      
        LINEid=`echo $LINE | cut -d '=' -f1` 
        msgid=`echo $LINE  | cut -d '"' -f2` 
        msgstr=`grep $LINEid $LOCfile | cut -d '"' -f2 | head -n1` 
        
        [ "`grep $LINEid $LOCfilePO`" ] && continue                         # avoid douplicates
        #echo "# $LINEid"
        #echo "msgid "$msgid""
        echo "msgstr "$msgstr""
        #echo ""

        echo "# $LINEid" >> $LOCfilePO
        echo "msgid "$msgid"" >> $LOCfilePO
        echo "msgstr "$msgstr"" >> $LOCfilePO
        echo "" >> $LOCfilePO

        ;;
   esac
  done < $TEMPLfile
  
  # create mo file and delete po file
  if [ "`msgfmt -o /usr/share/locale/$lang/LC_MESSAGES/$app.mo $LOCfilePO`" ]; then
   echo could not create /usr/share/locale/$lang/LC_MESSAGES/$app.mo
  else 
   rm $LOCfilePO
   echo /usr/share/locale/$lang/LC_MESSAGES/$app.mo created
  fi
  echo ''
 done # lang
 echo " ... $app converted"
 rm $SOURCE.converted
done # app
echo "finished

You can edit the translations using momanager
"
exit 0
And in the created /usr/local/ptiming-converted just change this:

Code: Select all

##set language
#. $APPDIR/locals/en_US:english #always run to fill gaps in translation
#LANGUAGE="`ls -1 $APPDIR/locals/ | grep ${LANG%.*}`"
##fallback to macrolanguage if available (ISO 639-1 two letter code: en, es, fr, etc.)
#if [ -z $LANGUAGE ]; then LANGUAGE="`ls -1 $APPDIR/locals/ | grep ${LANG%_*}:`"; fi
#[ "$LANGUAGE" != "en_US:english" ] && . $APPDIR/locals/$LANGUAGE 2> /dev/null 
#
Attachments
ptiming_converted.png
(30.03 KiB) Downloaded 729 times

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#37 Post by zigbert »

Pburn is updated with gettext - thanks a lot.

I have some time today - let's see what I get done..... will be back after the weekend


Sigmund

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

pburn

#38 Post by L18L »

zigbert wrote:Pburn is updated with gettext
downloaded version 3.7.4 shows as 3.7.3

Anyhow, I have converted all languages to pburn.mo using rodin.s `s version above.

So everyone will have to start not from zero


---

edit
going to test version now
Attachments
pburn_NLS.pet
some locals converted to pburn.mo
(48.96 KiB) Downloaded 631 times

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

Re: pfind

#39 Post by zigbert »

L18L wrote:Please test version 5.02
$TEXTDOMAIN=pfilesearch in your pFind. I guess it's because there only can be one text domain, and code from pFilesearch is embedded into pFind.

That means NLS files for pFilesearch will contain gettext-strings for both pFind and pFilesearch? Not the best solution for those who uses only pFilesearch as a backend for pBurn/pMusic.... My intention is to separate the backend and frontend.

What is the downside of having an unique $TEXTDOMAIN=pfind?


Sigmund

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: pfind

#40 Post by L18L »

zigbert wrote:$TEXTDOMAIN=pfilesearch in your pFind. I guess it's because there only can be one text domain, and code from pFilesearch is embedded into pFind.
Good guess!
That was before Barry changed momanager.
Now everything is possible:
I will separate them and make a version 5.03
TEXTDOMAIN=pfind
and pfilesearch using TEXTDOMAIN=pfilesearch containing the messages from pfilesearch only.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

Re: pfind

#41 Post by zigbert »

L18L wrote:
zigbert wrote:$TEXTDOMAIN=pfilesearch in your pFind. I guess it's because there only can be one text domain, and code from pFilesearch is embedded into pFind.
Good guess!
That was before Barry changed momanager.
Now everything is possible:
I will separate them and make a version 5.03
TEXTDOMAIN=pfind
and pfilesearch using TEXTDOMAIN=pfilesearch containing the messages from pfilesearch only.
Thank you.
I will be back Tuesday (probably).


Sigmund

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: pfind

#42 Post by L18L »

L18L wrote:I will separate them and make a version 5.03
TEXTDOMAIN=pfind
done
included is german pfind.mo so you can test changinging of GUI language

for testers only, delete /root/.pfind/pfindrc :arrow:

a lot of warnings like:
/usr/local/pfind/func: line 4: /tmp/pfind-TREE6413: Datei oder Verzeichnis nicht gefunden <-- not found
cat: /tmp/pfind-treeitems6413: Datei oder Verzeichnis nicht gefunden <-- not found
Attachments
pfind-5.03.pet
TEXTDOMAIN=pfind
was pfilesearch before
(23.33 KiB) Downloaded 558 times

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#43 Post by zigbert »

Ok, updated stuff


Thank you guys
Sigmund

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#44 Post by zigbert »

I have started on the next cycle of pMusic, and will add gettext to it

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

pburn

#45 Post by rodin.s »

Pburn doesn't switch to Russian automatically. But it does when 'ru' is selected in Preferences. Usually gettext doesn't need this manual language switching. The language of an application is defined by global locale settings of the system.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

Re: pburn

#46 Post by zigbert »

rodin.s wrote:Pburn doesn't switch to Russian automatically. But it does when 'ru' is selected in Preferences. Usually gettext doesn't need this manual language switching. The language of an application is defined by global locale settings of the system.
Does this occur only for pBurn or is it so for all the zigbert gettext apps?


Sigmund

User avatar
vicmz
Posts: 1262
Joined: Sun 15 Jan 2012, 22:47

#47 Post by vicmz »

To me that only happens with Pburn so far, Pmusic and Pprocess are usually set to the same language of the system. I don't know about the others, I haven't tried them yet.
[url=http://murga-linux.com/puppy/viewtopic.php?t=76948]Puppy Linux en español[/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: pburn

#48 Post by L18L »

zigbert wrote:
rodin.s wrote:Pburn doesn't switch to Russian automatically. But it does when 'ru' is selected in Preferences. Usually gettext doesn't need this manual language switching. The language of an application is defined by global locale settings of the system.
Does this occur only for pBurn or is it so for all the zigbert gettext apps?


Sigmund
Running pburn from latest precise 5.2.69
added
echo LANGUAGE=$LANGUAGE
to line 271 of /usr/local/pburn/pburn
my console wrote:# pburn
LANGUAGE=auto
EXIT="Ready"
gettext is using a LANGUAGE named auto here but for auto there is no pburn.mo :wink:

gettext uses automagically user´s language from LANG
-> the option auto has to be removed from the list of available languages
LANGUAGE is a system variable, do use it in its intended purpose only: http://www.gnu.org/software/gettext/man ... E-variable

Hope that helps :)

rodin.s
Posts: 344
Joined: Wed 22 Sep 2010, 19:50
Location: Ukraine

Re: pburn

#49 Post by rodin.s »

zigbert wrote:Does this occur only for pBurn or is it so for all the zigbert gettext apps?
Yes, it happens in pBurn only.
Interesting explanation from L18L.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#50 Post by zigbert »

Ok, I have changed $LANGUAGE to $MY_LANGUAGE, and added 2 lines after reading rc file. I had no idea gettext relies on $LANGUAGE.

Code: Select all

#set variables
. $CONFIG 2> /dev/null
export LANGUAGE="$MY_LANGUAGE"
[ "$MY_LANGUAGE" = "auto" ] && export LANGUAGE="${LANG%%_*}"
Attachments
pburn-3.7.5.pet
(67.08 KiB) Downloaded 469 times

Post Reply