writing a script for Puppy linux.
It shows the proper way to insert text (text widgets or buttons)
which have the apostrophe in the text string.
As well I show how to use Xdialog in an <action> tag.
It must be just one continuous line of code. \n is allowed by
Xdialog for several lines of text in the window.
Exporting of the variable is needed to get the string into Xdialog
which is a separate program. i.e. export TEXT3
Also note that two levels of quoting is sometimes necessary ie.
Code: Select all
"'$(gettext "Dick's Conversion")'"
See the following --->
Code: Select all
<action>Xdialog --title "'$(gettext "Dick's Conversion")'" --inputbox "'$(gettext "Dick's button")'\n" 0 0 "'$(echo '$TEXT3')'" &</action>
____________________________________________________
Note that the text string that is gettext'd is weak quoted i.e. double quoted
however 'My Book' string doesn't have an apostrophe so it can be strong quoted.
see image...
_________________________________________________________
You can save the script as experiment.sh and test it with momanager.
It will be easy to translate.
_______________________________________________________
The input file for the first entry box is a file with several lines in it
however only one line is read...
Code: Select all
<input file>'$WORKDIR'/default</input>
Here's the final image of window. Try clicking the buttons.
Code: Select all
#!/bin/bash
# apostrophe experiment
export TEXTDOMAIN=experiment.sh
export OUTPUT_CHARSET=UTF-8
export WORKDIR=/tmp/experiment
mkdir -p $WORKDIR
export TEXT1="$(gettext "Dick's Book")
$(gettext "Mary's Book")
$(gettext 'My Book')
$(gettext "Harry's Book")"
export TEXT2="$(gettext "Dick's Book
Mary's Book
My Book
Harry's Book")"
echo "$TEXT2" > $WORKDIR/default
export TEXT3="$(gettext "Mary's Example")"
export MAIN_DIALOG='
<window title="'$(gettext "Mary's Example")'" border-width="20">
<hbox>
<vbox space-expand="true" space-fill="true">
<text><label>"'$(gettext "Mary's Book
Harry's Book")'"</label></text>
<entry>
<input file>'$WORKDIR'/default</input>
<variable>RESULT1</variable>
</entry>
<entry>
<input>echo "'$(gettext "Mary's Book")'"</input>
<variable>RESULT2</variable>
</entry>
<hseparator></hseparator>
<text><label>"'$TEXT2'"</label></text>
<list>
<variable>LIST</variable>
<height>150</height>
<width>250</width>
<input file>'$WORKDIR'/default</input>
</list>
</vbox>
<vseparator></vseparator>
<vbox>
<button>
<label>'$(gettext "Dick's Conversion")'</label>
<action>Xdialog --title "'$(gettext "Dick's Conversion")'" --inputbox "'$(gettext "Dick's button")'\n" 0 0 "'$(echo '$TEXT3')'" &</action>
</button>
<button>
<label>'$(gettext "Mary's button")'</label>
<action>Xdialog --title "$TEXT3" --ok-label "'$(gettext "Mary's Closebox")'" --msgbox "$TEXT1 " 30 30 &</action>
</button>
<text space-expand="true"><label>""</label></text>
<button ok></button>
</vbox>
</hbox>
</window>'
gtkdialog --program=MAIN_DIALOG