Page 1 of 1

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

Posted: Wed 13 Feb 2013, 17:46
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

Posted: Wed 13 Feb 2013, 17:51
by Argolance
L18L wrote:maybe you add something to the title like
..and other goodies
Done!

Posted: Wed 13 Feb 2013, 19:19
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

.

Posted: Sat 16 Feb 2013, 19:54
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

.