See rules of eval_gettext in final post
This example shows how to use eval_gettext.
eval_gettext is an app that returns a textstring along with the contents of
a variable
gettext can only return some text string.
Instructions:
Save this script as 'script_example'. Check that it is executable and
place in an executable path. When the script is run some windows will
pop up. Check how 'echo' command is handled in the terminal.
Note that near beginning of script you must have written the script name
to tell momanager the script name to search for.
export TEXTDOMAIN=script_example
export OUTPUT_CHARSET=UTF-8
Warning! Do Not Put In line '. gettext.sh '
The bash manual says to do that but it just causes substitution problems.
Code: Select all
#!/bin/bash
#
export TEXTDOMAIN=script_example
export OUTPUT_CHARSET=UTF-8
TIME=4;VERSION=6.3
PATHWAY="/usr/share/My folder"
DESTINATION="${PATHWAY##*/}"
echo -e "`eval_gettext \" DESTINATION = \\\${PATHWAY##*/} \n \"; echo`"
Xdialog --msgbox "`eval_gettext \" DESTINATION = \\\${PATHWAY##*/} \n \"; echo`" 0 0
gxmessage "`eval_gettext \"Application \\\$VERSION\"; echo` $(gettext 'is running')"
echo -e "$( date ) `eval_gettext \"My Recorder \\\$VERSION\"; echo` \n"
echo "$( date ) `eval_gettext \"My Recorder \\\$VERSION\"; echo`" > "/root/my_log"
Xdialog --wrap --title "$(gettext 'Conversion underway.')" \
--yesno "`eval_gettext \"\nTime of conversion: \\\$TIME seconds.\"; echo`\n" 0 0
export EXAMPLE='
<window title="'"`eval_gettext \"Tom's Recorder \\\$VERSION\"; echo`"'">
<frame '"`eval_gettext \"Dick's Recorder \\\$VERSION\"; echo`"'>
<text width-request="300">
<label>"'"`eval_gettext \"Harry's Recorder \\\$VERSION\"; echo`"'"</label>
</text>
<button>
<label>"'"`eval_gettext \"Charlie's Button \\\$VERSION\"; echo`"'"</label>
<action>Xdialog --msgbox "'"$(gettext "Mary's message") $(gettext 'costs \$10')"'" 0 0</action>
</button>
</frame>
</window>'
gtkdialog -p EXAMPLE
To check how it is translated into a foreign language
Instructions:
1) load devx file for your puppy
2) install poedit (optional)
3) set language for your computer , for example French
4) Launch momanager
Utilities > Momanager
5) Tick poedit box if you have installed it
6) Find the script name on list
7) Click 'Create'
Here is resulting poedit output. It's easy to translate now.
The 'script_example.mo' file is created when you quit poedit.
Tip: Be sure that your script contains only ascii characters.
Test you script with this command in the termiinal.
The line number where there is a bad character usually utf-8 will
be signalled.
Code: Select all
xgettext -L shell script_example -o -
1) To stop a substitution I put a slash in front of dollar sign($)
$(gettext 'costs \$10')
2) Note that eval_gettext works very well with the apostrophe