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 Tue 23 Sep 2014, 22:49
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
gettext: escape single quotes... and other goodies [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [19 Posts]   Goto page: 1, 2 Next
Author Message
Argolance


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

PostPosted: Thu 31 Jan 2013, 10:31    Post subject:  gettext: escape single quotes... and other goodies [SOLVED]  

Hello,
Using gettext, this works:
Quote:
<text><label>$(gettext 'I know')</label></text>

But this doesn't:
Quote:
<text><label>$(gettext 'I don't know')</label></text>
It is not the first time I encounter this problem. So far, I was used to get around the problem by writing:
Quote:
<text><label>$(gettext 'I do not know')</label></text>
or
Quote:
<text><label>$(gettext "I don't know ")</label></text>
I would rather like to know if there is any character which could let me escape single quotes inside a chain?

Thank you!
Cordialement.

Last edited by Argolance on Wed 13 Feb 2013, 15:42; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website 
postfs1


Joined: 27 Mar 2010
Posts: 831

PostPosted: Thu 31 Jan 2013, 10:59    Post subject:  

BASH wrote:

Code:

echo 'I don'"'"'t know'


OUTPUT IN BASH wrote:

I don't know



_________________
  • I don't know why laboratories are named a hospitals.
  • The alive personage is like a tea bag with granules of unknown density inside, at that one the packet was made of organic material and was placed in the evaporated liquid or liquid.

Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Thu 31 Jan 2013, 11:49    Post subject:  

Hello postfs1,
Very Happy Very Happy
Thank you!

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Sat 02 Feb 2013, 17:02    Post subject:  

Another solution...

utf-8 characters i.e. unicode has other quote characters
available to users.

I open up Abiword and go to the top menu

Insert > symbol

and find another quote symbol in dejavu font.

___________________________________________________
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Sun 03 Feb 2013, 06:45    Post subject:  

Thanks!
Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Tue 05 Feb 2013, 18:22    Post subject: apostrophe in gettext  

I've been experimenting using pupmd5sum.sh

As an example I try to make a button label showing 'John's message'
This was able to work...

Code:

<button>
     <label>'"$(gettext "John's message")"'</label>
     <action>checkfunc '"$ENT1"'</action>
     <action type="refresh">ENT2</action>
</button>






BTN1=$(gettext 'John's message')
resulted in an error
unexpected EOF while looking for matching `)'
________________________________________________________


Edit: deleted a section because of bad info


_________________________________________

Last edited by don570 on Mon 11 Feb 2013, 19:11; edited 2 times in total
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: Wed 06 Feb 2013, 06:28    Post subject: Re: apostrophe in gettext  

don570 wrote:

Also I could do a substitution like this...

First define variable ABC

ABC="John's message"

then BTN1 becomes...
BTN1=$(gettext "$ABC")


________________________________________________________


Did translation work Question

If so forget eval_gettext
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Thu 07 Feb 2013, 15:06    Post subject:  

L18L wrote:
Did translation work?


That's a good question? I was just trying the English.

When I translated build_gettext I found that the English would work and
the translations into German and French wouldn't work. So I should have
known better Embarassed

I'll take the time to test thoroughly and report back on Saturday.
______________________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Sat 09 Feb 2013, 14:55    Post subject:  

When I made a fresh frugal install of precise the launch speed
of MoManager was much faster (35 seconds) , but now it has slowed
down again after I installed a few scripts.

_________________________________________________

I have found that yaf-splash can be tricky to gettext properly.

Code:
yaf-splash -close box -fontsize large -bg orange -fb black -text  " $(gettext 'Sorry.  'devx' file must be loaded.')"


works properly when typed in the terminal and in English,
but the strong quotes confuse Momanager so that a German translation
is impossible, but change the outer quotes to double(as shown below)
will make the script translate properly with MoManager.

Code:
yaf-splash -close box -fontsize large -bg orange -fb black -text  " $(gettext "Sorry.  'devx' file must be loaded.")"


.

Last edited by don570 on Sat 09 Feb 2013, 15:38; edited 1 time in total
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Sat 09 Feb 2013, 15:15    Post subject:  

I checked the button labels with a German translation with MoManager.


This works for a button
<label>'$(gettext "Jim's text")'</label>

This won't work
<label>"$(gettext "Jim's text")"</label>

________________________________________________

Then I checked an assigned variable inside the gettext expression...
I did translations into German --> expressions with an apostrophe.



This works
<label>'"$BTN1"'</label>

and this works
<label>'$BTN1'</label>

Here was the output in German language



________________________________________________________
This didn't work
<label>"$BTN1"</label>


.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Mon 11 Feb 2013, 19:18    Post subject: multiple lines of translated text in a yaf-splash window  

The only method I found to place multiple lines of translated text in
a yaf-splash window....

Breakup a large amount ot text into lines of text.
Text can have apostrophe.


Code:
TEXT1=$(gettext ".......")
TEXT2=$(gettext ".......")
TEXT3=$(gettext ".......")
TEXT4=$(gettext ".......")


Then invoke yaf-splash with the code

Code:

yaf-splash -close box -fontsize large -bg orange -fb black -text  " $TEXT1
$TEXT2
$TEXT3
$TEXT4
"


.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Mon 11 Feb 2013, 19:57    Post subject:  

Xdialog was more flexible than yaf-splash. Breaking the text into lines
can also be used with Xdialog, however the following method using \\n
is more useful....

Note: two Escapes \\ should be used (one Escape \ is possible
but should be avoided)

Code:
TEXT1=$(gettext "John's text \\nSecond line\\nThird line")
Xdialog  --ok-label "OK" --backtitle "\n  $TEXT1 \n "  --msgbox  "" 0 0


Here is a sample of the output of Poedit. (Note the double 'Escapes')



And here is the final output in English first then German




_____________________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Mon 11 Feb 2013, 20:07    Post subject:  

Some notes about Xdialog

1) left justification option ( --left) makes a large amount
of text look neater

2) Geometry of 0 0 forces the size of the window to resize to
fit the text.

3) Warning: Lines of Foreign language text are often longer than English.

.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3294
Location: Ontario

PostPosted: Mon 11 Feb 2013, 20:18    Post subject:  

I tested eval_gettext using the instructions HERE

you must put the following line before evoking eval_gettext

Code:
. gettext.sh


A variable contains the output of a command. Here's the example...

Code:
filecount="`ls | wc -l`"
eval_gettext "Remaining files: \$filecount"; echo


Now that the script is ready for translation , switch to German with
country Wizard , and run Momanager/Poedit.



You can now do the translation into German.

Run script in terminal, and here is output...
(script_name is pupmd5sum5.sh)





In the terminal

Last edited by don570 on Wed 13 Feb 2013, 14:24; edited 1 time in total
Back to top
View user's profile Send private message 
Argolance


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

PostPosted: Wed 13 Feb 2013, 07:42    Post subject:  

Hello,
I didn't see your posts before although "Notify me when a reply is posted" was checked. Confused
Very interesting!
But "gettexting" a script (using different xxxmessage inside) is finally complex to handle... As you walked around the problem, this thread became a very useful "tutorial"... Very Happy
Thank you.

Cordialement.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 2 [19 Posts]   Goto page: 1, 2 Next
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.1005s ][ Queries: 12 (0.0127s) ][ GZIP on ]