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.