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 21 Aug 2014, 06:30
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 [4 Posts]  
Author Message
don570


Joined: 10 Mar 2010
Posts: 3250
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.
Code:
"'$(gettext "Dick's Conversion")'"

The strong quoting allows the execution of gettext program

See the following --->

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



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




Code:

#!/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


_____________________________________________________

Last edited by don570 on Wed 19 Mar 2014, 18:50; edited 1 time in total
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 372
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 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

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 
Argolance


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

PostPosted: Mon 05 May 2014, 06:00    Post subject:  

Great!
Thanks don570...
Quote:
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!

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0677s ][ Queries: 12 (0.0044s) ][ GZIP on ]