Page 1 of 1
gettext: escape single quotes... and other goodies [SOLVED]
Posted: Thu 31 Jan 2013, 14:31
by Argolance
Hello,
Using gettext, this works:
<text><label>$(gettext 'I know')</label></text>
But this doesn't:
<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:
<text><label>$(gettext 'I do not know')</label></text>
or
<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.
Posted: Thu 31 Jan 2013, 14:59
by postfs1
OUTPUT wrote:
I don't know
Posted: Thu 31 Jan 2013, 15:49
by Argolance
Hello postfs1,
Thank you!
Cordialement.
Posted: Sat 02 Feb 2013, 21:02
by don570
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.
___________________________________________________
Posted: Sun 03 Feb 2013, 10:45
by Argolance
Thanks!
apostrophe in gettext
Posted: Tue 05 Feb 2013, 22:22
by don570
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: Select all
<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
_________________________________________
Re: apostrophe in gettext
Posted: Wed 06 Feb 2013, 10:28
by L18L
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
If so forget
eval_gettext
Posted: Thu 07 Feb 2013, 19:06
by don570
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
I'll take the time to test thoroughly and report back on Saturday.
______________________________________________________
Posted: Sat 09 Feb 2013, 18:55
by don570
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: Select all
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: Select all
yaf-splash -close box -fontsize large -bg orange -fb black -text " $(gettext "Sorry. 'devx' file must be loaded.")"
.
Posted: Sat 09 Feb 2013, 19:15
by don570
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>
.
multiple lines of translated text in a yaf-splash window
Posted: Mon 11 Feb 2013, 23:18
by don570
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: Select all
TEXT1=$(gettext ".......")
TEXT2=$(gettext ".......")
TEXT3=$(gettext ".......")
TEXT4=$(gettext ".......")
Then invoke yaf-splash with the code
Code: Select all
yaf-splash -close box -fontsize large -bg orange -fb black -text " $TEXT1
$TEXT2
$TEXT3
$TEXT4
"
.
Posted: Mon 11 Feb 2013, 23:57
by don570
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: Select all
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
_____________________________________________________
Posted: Tue 12 Feb 2013, 00:07
by don570
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.
.
Posted: Tue 12 Feb 2013, 00:18
by don570
I tested eval_gettext using the instructions
HERE
you must put the following line before evoking eval_gettext
A variable contains the output of a command. Here's the example...
Code: Select all
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
Posted: Wed 13 Feb 2013, 11:42
by Argolance
Hello,
I didn't see your posts before although "Notify me when a reply is posted" was checked.
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"...
Thank you.
Cordialement.
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
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
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...
.
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...
.