Author |
Message |
Argolance

Joined: 06 Jan 2008 Posts: 3822 Location: PORT-BRILLET (Mayenne - France)
|
Posted: 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
|
|
 |
postfs1
Joined: 27 Mar 2010 Posts: 820
|
Posted: Thu 31 Jan 2013, 10:59 Post subject:
|
|
Quote: |
Code: |
busybox echo 'I don'"'"'t know'
|
OUTPUT wrote: |
I don't know
|
|
Last edited by postfs1 on Sun 27 Mar 2016, 17:21; edited 6 times in total
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3822 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Thu 31 Jan 2013, 11:49 Post subject:
|
|
Hello postfs1,
Thank you!
Cordialement.
_________________
Puppy Search
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3822 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Sun 03 Feb 2013, 06:45 Post subject:
|
|
Thanks!
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
L18L

Joined: 19 Jun 2010 Posts: 3493 Location: www.eussenheim.de/
|
Posted: 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
If so forget eval_gettext
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
I'll take the time to test thoroughly and report back on Saturday.
______________________________________________________
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 5524 Location: Ontario
|
Posted: 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
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
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3822 Location: PORT-BRILLET (Mayenne - France)
|
Posted: 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.
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.
|
Back to top
|
|
 |
|