Page 2 of 4

pfind

Posted: Sat 04 Aug 2012, 18:24
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.......

Re: Gettext in pBurn.

Posted: Sat 04 Aug 2012, 18:35
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

zigbert2gettext-0.1

Posted: Sun 05 Aug 2012, 11:05
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.

Posted: Sun 05 Aug 2012, 11:18
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

pBurn updated

Posted: Sun 05 Aug 2012, 13:42
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.

ptiming

Posted: Sun 05 Aug 2012, 18:11
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 
#

Posted: Fri 10 Aug 2012, 06:28
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

pburn

Posted: Fri 10 Aug 2012, 10:54
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

Re: pfind

Posted: Fri 10 Aug 2012, 11:09
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

Re: pfind

Posted: Fri 10 Aug 2012, 11:48
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.

Re: pfind

Posted: Fri 10 Aug 2012, 12:11
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

Re: pfind

Posted: Fri 10 Aug 2012, 14:06
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

Posted: Mon 13 Aug 2012, 09:23
by zigbert
Ok, updated stuff


Thank you guys
Sigmund

Posted: Sat 18 Aug 2012, 08:18
by zigbert
I have started on the next cycle of pMusic, and will add gettext to it

pburn

Posted: Sun 26 Aug 2012, 19:51
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.

Re: pburn

Posted: Sun 26 Aug 2012, 19:54
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

Posted: Sun 26 Aug 2012, 20:47
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.

Re: pburn

Posted: Mon 27 Aug 2012, 19:16
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 :)

Re: pburn

Posted: Mon 27 Aug 2012, 20:13
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.

Posted: Tue 28 Aug 2012, 06:16
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%%_*}"