Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 19 Apr 2014, 13:19
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Substitution of chain in a gtkdialog menu [SOLVED]
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 1779
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: 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
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1779
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2473
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: 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
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1779
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0592s ][ Queries: 11 (0.0073s) ][ GZIP on ]