banzai has asked for the wisdom of the Perl Monks concerning the following question:
What I want to do is make my GUI startable in different languages. I would input a parameter when starting the gui (e.g. perl gui.pl english) and when initialising the widgets it would get the text from a xml file that looks like this:
<?xml version="1.0"?> <language> <english> <widget ID="1">input</widget> <widget ID="2">output</widget> </english> <deutsch> <widget ID="1">eingabe</widget> <widget ID="2">ausgabe</widget> </deutsch> </language>
in the text setting of widgets i call a function with the widget id as a parameter.
sub change_lang { my $id= shift; my $file='lang.xml'; my $result; my $parser = XML::LibXML->new(); my $tree = $parser->parse_file($file); $result=$tree->findnodes("/language/$language/widget[@ID="$id"]"); return $result; }
but that doesnt work ("global symbol @ID requires explicit package name"). I don't know how to get to the content of the xml with scalars in the findnodes path. how would i do this? If anyone has better ideas for implementing language change, I'd be open for it, too. I'm too much of a perl scrub.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: language selection via libxml
by McA (Priest) on Jan 20, 2014 at 09:40 UTC | |
by tangent (Parson) on Jan 20, 2014 at 12:18 UTC | |
by choroba (Cardinal) on Jan 20, 2014 at 12:29 UTC | |
by tangent (Parson) on Jan 20, 2014 at 12:41 UTC | |
by choroba (Cardinal) on Jan 20, 2014 at 13:09 UTC | |
| |
by hdb (Monsignor) on Jan 20, 2014 at 12:52 UTC | |
| |
|
Re: language selection via libxml (perlquote)
by Anonymous Monk on Jan 20, 2014 at 09:53 UTC | |
|
Re: language selection via libxml
by Jenda (Abbot) on Jan 20, 2014 at 17:05 UTC |