gettext: escape single quotes... and other goodies [SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

gettext: escape single quotes inside a chain? [SOLVED]

#16 Post by L18L »

Argolance wrote:... this thread became a very useful "tutorial"...
+1 :D

Argolance,
maybe you add something to the title like
..and other goodies

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#17 Post by Argolance »

L18L wrote:maybe you add something to the title like
..and other goodies
Done!
Last edited by Argolance on Thu 14 Feb 2013, 08:41, edited 1 time in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#18 Post by don570 »

...continuing the tutorial :wink:

I tested eval_gettext using the instructions HERE

You can use the echoed text in useful situations. Here's an example with
yaf-splash. Take the echo of eval_gettext command

Code: Select all

eval_gettext "Remaining files: \$filecount"; echo
... and put backquotes around it to make a command's output text
and stick it in a standard yaf-splash line.

Code: Select all

yaf-splash -close box -fontsize large -bg orange -fb black \
-text  "`eval_gettext \"Remaining files: \\\$filecount\"; echo`"
Notes:

1) Double quote character( " ) needs to be escaped i.e. \

2) The dollar sign character($) needs three 'Escapes' i.e. \\\


Here is the output of localised script in German...

Image

.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#19 Post by don570 »

Here's another useful example this time with an Xdialog command
with multiple lines of text in the action line of a button.

First define a variable 'MESSAGE'

Warning ! 'Export' of variable must be used.

Code: Select all

export MESSAGE=$(gettext "John's message\\nin the office") 

Here is the action line of the button...

Code: Select all

<action>Xdialog  --ok-label "$BTN4" --backtitle "\n\n    $MESSAGE  "  --msgbox  "" 0 0</action> 
Here is the output if translated to French...


Image

.

Post Reply