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 Tue 21 Oct 2014, 12:50
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 Posts_count  
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 1835
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.

_________________


Edited_time_total
Back to top
View user's profile Send_private_message Visit_website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
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_website 
Argolance


Joined: 06 Jan 2008
Posts: 1835
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_website 
L18L

Joined: 19 Jun 2010
Posts: 2525
Location: Moved from Hosla to www.eussenheim.de

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: 1835
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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0582s ][ Queries: 12 (0.0053s) ][ GZIP on ]