diff options
-rw-r--r-- | extras/conf/mpan/settings.conf | 6 | ||||
-rw-r--r-- | lib/ManaTools/MainDisplay.pm | 26 | ||||
-rw-r--r-- | lib/ManaTools/SettingsReader.pm | 14 |
3 files changed, 41 insertions, 5 deletions
diff --git a/extras/conf/mpan/settings.conf b/extras/conf/mpan/settings.conf index 16389b47..6e23487e 100644 --- a/extras/conf/mpan/settings.conf +++ b/extras/conf/mpan/settings.conf @@ -1,8 +1,10 @@ <?xml version='1.0'?> <settings> - <title>Mageia Panel</title> + <title xml:lang="en">Mageia Panel</title> + <title xml:lang="it">Pannello di controllo Mageia</title> <!--logo>PATHNAME</logo> <icon>PATHNAME</icon--> - <category_title>Categories</category_title> + <category_title xml:lang="en">Categories</category_title> + <category_title xml:lang="it">Categorie</category_title> <priv_method>pkit</priv_method> </settings> diff --git a/lib/ManaTools/MainDisplay.pm b/lib/ManaTools/MainDisplay.pm index b329a8c9..9437ef0b 100644 --- a/lib/ManaTools/MainDisplay.pm +++ b/lib/ManaTools/MainDisplay.pm @@ -55,6 +55,7 @@ ManaTools::MainDisplay - class for ManaTools main window use Moose; extends qw( ManaTools::Module ); +use I18N::LangTags::Detect; use diagnostics; use ManaTools::SettingsReader; @@ -602,7 +603,30 @@ sub _loadSettings { if (! scalar %{$self->settings()} || $force_load) { my $settingsReader = ManaTools::SettingsReader->new({fileName => $fileName}); - $self->settings($settingsReader->settings()); + + my $settings; + my @lang = I18N::LangTags::Detect::detect(); + my $read = $settingsReader->settings(); + foreach (keys %{$read}) { + my $key = $_; + # localized strings + if ($key eq "title" or $key eq "category_title") { + # default is en + $settings->{$key} = $read->{$key}->{en}; + foreach my $l ( @lang ) { + if ($read->{$key}->{$l}) { + $settings->{$key} = $read->{$key}->{$l}; + last; + } + } + $self->logger()->I($self->loc()->N("%s content is <<%s>>", $key, $settings->{$key})); + } + else { + $settings->{$key} = $read->{$key}; + } + } + + $self->settings($settings); } } diff --git a/lib/ManaTools/SettingsReader.pm b/lib/ManaTools/SettingsReader.pm index 99e5ad5d..e1c49f25 100644 --- a/lib/ManaTools/SettingsReader.pm +++ b/lib/ManaTools/SettingsReader.pm @@ -98,8 +98,18 @@ has 'settings' => ( sub _settingsInitialize { my $self = shift; - my $xml = new XML::Simple (KeyAttr=>[]); - return $xml->XMLin($self->fileName()); + my $xml = new XML::Simple (); + my $cont = $xml->XMLin( + $self->fileName(), + ContentKey => '-content', + ForceArray => ['title', 'category_title'], + KeyAttr => { + title => "xml:lang", + category_title => "xml:lang", + } + ); + + return $cont; } no Moose; |