Author |
Message |
Argolance

Joined: 06 Jan 2008 Posts: 3255 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Wed 25 Jul 2012, 12:56 Post subject:
Substitution of chain in a gtkdialog menu [SOLVED] |
|
Hello,
Code: | Name=Application English name
Name[fr]=Nom français de l'application
Name[de]=...
Name[es]=... |
... The script below fetches the value of the variable LANGUE in the configuration file above.
English being the language by default, [en] is not specified but only "Name=" and that's where the shoe pinches... Quote: | #! /bin/sh
export test_GUI="<window>
<menubar>
<menu label=\"TEST\">
<menuitem label=\"$(grep '^Name\['$LANGUE\]' /path/config_file | cut -d'=' -f2) ${label="$(grep '^Name=' /path/config_file | cut -d'=' -f2)"}\">
</menuitem>
</menu>
</menubar>
</window>"
gtkdialog --program=test_GUI --center | The label of the menu is displayed in English if the value does not exist in the configuration file or simply because the current language of the user is English.
But on the other hand, both labels (current language and English) are displayed simultaneously when the value exists!
I just want the current language label to be displayed.
How could I solve this?
Hard to explain in English...
Thank you for your attention!
Cordialement.
_________________

Last edited by Argolance on Mon 30 Jul 2012, 10:48; edited 1 time in total
|
Back to top
|
|
 |
Karl Godt

Joined: 20 Jun 2010 Posts: 4208 Location: Kiel,Germany
|
Posted: Wed 25 Jul 2012, 14:44 Post subject:
|
|
i am not a fan of these massive code constructs inside gtkdialog .
I would assign the grep 'ed values before launching gtkdialog
like
Code: | label_native=$(grep '^Name\[$LANGUE\]' /path/config_file | cut -d'=' -f2)
label_default="$(grep '^Name=' /path/config_file | cut -d'=' -f2)"
label_use="$label_default"
if [ "$label_native" ];then
label_use="$label_native"
fi
[ "$label_use" ] || { echo "$0:$LINENO::ERROR, label_use declared but not filled.";exit 100; }
export MAIN_DIALOG="
<window>
<text><label>$label_use</label></text>
</window>
"
gtkdialog3 -p MAIN_DIALOG
|
I tried to source config.file first to use arrays,
but that must a) eval 'uated and b) needs "Name of Pro'gram" quoted .
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3255 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Thu 26 Jul 2012, 05:55 Post subject:
|
|
Hello,
Thank you for replying.
Quote: | i am not a fan of these massive code constructs inside gtkdialog | ...Yes, as we sometimes say in French, speaking of "heavy" red wine: this is a big one that stains!
As I got a lot of entries inside my menus, I am trying to find another "lighter" solution: directly build correct config files for example should probably be the best!
Cordialement.
_________________

|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 3431 Location: www.eussenheim.de/
|
Posted: Thu 26 Jul 2012, 07:52 Post subject:
|
|
Argolance wrote: | ...As I got a lot of entries inside my menus, I am trying to find another "lighter" solution: directly build correct config files for example should probably be the best! |
Something like
s%"Application English name" %"Nom allemand de l'application"%
s%"bla English" %"bla allemand"%
is implemented in /usr/share/sss/menu_strings/menu_strings.de
I have used it for configuration of jwm menu in langpack_de.
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 3255 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Mon 30 Jul 2012, 10:46 Post subject:
|
|
Hello,
Thank you!
I finally chose to "operate" not in "downstream" but in "upstream", simply building adapted configuration files, and now all is working fine.
Very interesting to learn that fixmenus reads raw English template files and generates final target files, then translates them in-place.
Code: | s%"Help"%"Hilfe"%
... | This looks like a simple sed command...
Cordialement.
_________________

|
Back to top
|
|
 |
|