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 Thu 02 Jul 2015, 06:09
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
gettext - the use of the apostrophe
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message

Joined: 10 Mar 2010
Posts: 3778
Location: Ontario

PostPosted: Tue 18 Mar 2014, 19:58    Post_subject:  gettext - the use of the apostrophe  

Here is an example for programmers to use as a guide when
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.
"'$(gettext "Dick's Conversion")'"

The strong quoting allows the execution of gettext program

See the following --->

<action>Xdialog --title "'$(gettext "Dick's Conversion")'" --inputbox "'$(gettext "Dick's button")'\n" 0 0 "'$(echo '$TEXT3')'" &</action>

Note that the above is all one line of code.


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...
<input file>'$WORKDIR'/default</input>

Here's the final image of window. Try clicking the buttons. Laughing


# apostrophe experiment

export TEXTDOMAIN=experiment.sh
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">
<vbox space-expand="true" space-fill="true">
                      <text><label>"'$(gettext "Mary's Book
Harry's Book")'"</label></text>
                                <input file>'$WORKDIR'/default</input>               
                                 <input>echo "'$(gettext "Mary's Book")'"</input>               
                     <input file>'$WORKDIR'/default</input>                                 
              <label>'$(gettext "Dick's Conversion")'</label>
              <action>Xdialog --title "'$(gettext "Dick's Conversion")'" --inputbox "'$(gettext "Dick's button")'\n" 0 0 "'$(echo '$TEXT3')'" &</action>   
              <label>'$(gettext "Mary's button")'</label>
              <action>Xdialog --title "$TEXT3" --ok-label "'$(gettext "Mary's Closebox")'" --msgbox "$TEXT1 " 30 30 &</action>   
              <text space-expand="true"><label>""</label></text>
              <button ok></button>     
gtkdialog --program=MAIN_DIALOG


Back to top
View user's profile Send_private_message 

Joined: 12 Oct 2012
Posts: 702
Location: The other Mr. 305

PostPosted: Wed 19 Mar 2014, 14:44    Post_subject:  

Once again, I appreciate your work and tutelage. I have been piecing together a bunch of useful bash scripts and I've been considering a nicer interface. I wasn't so interested in the apostrophe as I was with the actual end product. Good stuff.
Back to top
View user's profile Send_private_message 

Joined: 19 Jun 2010
Posts: 2943
Location: www.eussenheim.de/

PostPosted: Thu 27 Mar 2014, 14:43    Post_subject: gettext - the use of the apostrophe  

I plead guilty to have changed sometimes some original messages to avoid these issues, e.g. changed isn't to is not,.... Embarassed

Well done don thank you
Back to top
View user's profile Send_private_message 

Joined: 06 Jan 2008
Posts: 2069
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 05 May 2014, 06:00    Post_subject:  

Thanks don570...
I plead guilty to have changed sometimes some original messages to avoid these issues, e.g. changed isn't to is not,....

All the same!



Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0700s ][ Queries: 11 (0.0033s) ][ GZIP on ]