aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-04-29 16:04:54 +0200
committerAngelo Naselli <anaselli@linux.it>2015-04-29 16:04:54 +0200
commitc4619ac939b35cc7043c66d3789f4aec44b23e90 (patch)
tree52951db3a75ce6b29a6d5a7774825ed7fe9cff5d /scripts
parentd3a0213284064deb0e936939caf590bb50890e90 (diff)
downloadmanatools-c4619ac939b35cc7043c66d3789f4aec44b23e90.tar
manatools-c4619ac939b35cc7043c66d3789f4aec44b23e90.tar.gz
manatools-c4619ac939b35cc7043c66d3789f4aec44b23e90.tar.bz2
manatools-c4619ac939b35cc7043c66d3789f4aec44b23e90.tar.xz
manatools-c4619ac939b35cc7043c66d3789f4aec44b23e90.zip
Added localization in mana script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mana57
1 files changed, 34 insertions, 23 deletions
diff --git a/scripts/mana b/scripts/mana
index 234be238..37c6db95 100755
--- a/scripts/mana
+++ b/scripts/mana
@@ -23,72 +23,82 @@
#*****************************************************************************
use ManaTools::Privileges;
+use ManaTools::Shared::Locales;
use yui;
-# TODO from configuration file?
-# TODO localization for descriptions
+my $cmdline = new yui::YCommandLine;
+my $locale_dir = undef;
+my $pos = $cmdline->find("--locales-dir");
+if ($pos > 0)
+{
+ $locale_dir = $cmdline->arg($pos+1);
+}
+my $loc = ManaTools::Shared::Locales->new(
+ domain_name => 'manatools',
+ dir_name => $locale_dir,
+);
+
my %modules = (
log => {
exec => '/usr/bin/manalog',
- descr => "manalog: journalct log reader",
+ descr => $loc->N("manalog: journalct log reader"),
},
user => {
exec => '/usr/bin/manauser',
- descr => "manauser: user manager",
+ descr => $loc->N("manauser: user manager"),
},
service => {
exec => '/usr/bin/manaservice',
- descr => "manaservice: service manager",
+ descr => $loc->N("manaservice: service manager"),
user_mode => 1,
},
dm => {
exec => '/usr/bin/manadm',
- descr => "manadm: login manager configuration",
+ descr => $loc->N("manadm: login manager configuration"),
},
clock => {
exec => '/usr/bin/manaclock',
- descr => "manaclock: date/time manager",
+ descr => $loc->N("manaclock: date/time manager"),
},
host => {
exec => '/usr/bin/manahost',
- descr => "manahost: hosts manager",
+ descr => $loc->N("manahost: hosts manager"),
},
pan => {
exec => '/usr/bin/mpan',
- descr => "mpan: admin panel",
+ descr => $loc->N("mpan: admin panel"),
},
proxy => {
exec => '/usr/bin/manaproxy',
- descr => "manaproxy: proxy manager",
+ descr => $loc->N("manaproxy: proxy manager"),
},
rpm => {
exec => '/usr/bin/rpmdragora',
- descr => "rpmdragora: rpm install manager",
+ descr => $loc->N("rpmdragora: rpm install manager"),
},
update => {
exec => '/usr/bin/dragoraUpdate',
- descr => "dragoraUpdate: rpm update manager",
+ descr => $loc->N("dragoraUpdate: rpm update manager"),
},
wall => {
exec => '/usr/bin/manawall',
- descr => "manawall: firewall manager",
+ descr => $loc->N("manawall: firewall manager"),
},
);
-my $cmdline = new yui::YCommandLine;
-
usage() if($cmdline->find("--help") > 0 || $cmdline->find("-h") > 0);
usage() if scalar(@ARGV) < 1;
my $cmd = $ARGV[0];
-die "Command ". $cmd . " not found!\n" if !defined($modules{$cmd});
+eval {
-my $mod = $modules{$cmd}->{exec};
-shift(@ARGV);
+ die $loc->N("Command <%s> not found!\n", $cmd) if !defined($modules{$cmd});
+
+ my $mod = $modules{$cmd}->{exec};
+ shift(@ARGV);
-eval {
if(!$modules{$cmd}->{user_mode} && is_root_capability_required()) {
system("/usr/bin/pkexec", $mod, @ARGV);
} else {
@@ -96,7 +106,8 @@ eval {
}
};
if ( $@ ) {
- print "ERROR: " . $@ ."\n";
+ print "\n" . $loc->N("ERROR: ") . $@ ;
+ usage(),
}
#=============================================================
@@ -114,9 +125,9 @@ usage print the mana usage help
sub usage {
print "\n";
- print "Usage mana --help | -h print this help\n";
- print "Usage mana <command> [args...]\n\n";
- print "valid <commands>:\n";
+ print $loc->N("Usage mana --help | -h print this help\n");
+ print $loc->N("Usage mana <command> [args...]\n\n");
+ print $loc->N("valid <commands>:\n");
foreach my $key (sort keys %modules) {
# lenght + 2 chars "<" and ">"