New Portuguese (Portugal) translation by Pedro Albuquerque
[clawsker.git] / clawsker
index 9cef429267e50bd6ac313cd5aa2adf43c6838aa6..4428dd439852b5eb590b9059f78506298f5e4212 100755 (executable)
--- a/clawsker
+++ b/clawsker
@@ -20,6 +20,8 @@ use utf8;
 use version 0.77;
 use Glib qw(TRUE FALSE);
 use Gtk3;
+use File::Which;
+use File::Spec::Functions;
 use POSIX qw(setlocale);
 use Locale::gettext;
 use Encode;
@@ -39,7 +41,7 @@ my $main_window = undef;
 my $locale = (defined($ENV{LC_MESSAGES}) ? $ENV{LC_MESSAGES} : $ENV{LANG});
 $locale = "C" unless defined($locale);
 setlocale (LC_ALL, $locale);
-bindtextdomain ($NAME, sprintf ('%s/share/locale', $PREFIX));
+bindtextdomain ($NAME, catdir ($PREFIX, 'share', 'locale'));
 textdomain ($NAME);
 
 sub _ {
@@ -56,25 +58,7 @@ sub _ {
 
 # default messages
 %xl::s = (
-    win_title => _('Claws Mail Hidden Preferences'),
     about_title => _('Clawsker :: A Claws Mail Tweaker'),
-    about_web_label => _("Visit Clawsker's web page"),
-
-    error_title => _('Clawsker error'),
-
-    exit_title => _('Clawsker warning'),
-    exit_fact => _('There are unapplied modifications.'),
-    exit_question => _('Do you really want to quit?'),
-
-    tab_colours => _('Colours'),
-    tab_behaviour => _('Behaviour'),
-    tab_gui => _('GUI'),
-    tab_other => _('Other'),
-    tab_winpos => _('Windows'),
-    tab_accounts => _('Accounts'),
-    tab_plugins => _('Plugins'),
-    tab_hotkeys => _('Hotkeys'),
-    tab_info => _('Info'),
 
     l_oth_use_dlg => _('Use detached address book edit dialogue'),
     h_oth_use_dlg => _('If true use a separate dialogue to edit a person\'s details. Otherwise will use a form embedded in the address book\'s main window.'),
@@ -256,7 +240,7 @@ my %ACHPVALUE = ();
 my %PLHPVALUE = ();
 # default config dir and file name
 my $ALTCONFIGDIR = FALSE;
-my $CONFIGDIR = $ENV{HOME} . '/.claws-mail/';
+my $CONFIGDIR = catdir ($ENV{HOME}, '.claws-mail');
 my $CONFIGRC = 'clawsrc';
 my $ACCOUNTRC = 'accountrc';
 # supported and available plugins lists
@@ -283,12 +267,17 @@ use constant {
     # constants for GUI spacing
     HBOX_PAD => 5,
     GRID_SPC => 10,
+    # for data references indexing
+    VALUE => 0,
+    IVALUE => 1,
+    # hotkey list store columns
+    C_LABEL => 0,
+    C_HOTKEY => 1,
+    C_GROUP => 2,
+    C_ACCEL => 3,
+    C_ODDITY => 4,
 };
 
-# for data references indexing
-use constant VALUE => 0;
-use constant IVALUE => 1;
-
 # version functions
 
 sub version_greater_or_equal {
@@ -300,9 +289,8 @@ sub version_greater_or_equal {
 }
 
 sub get_claws_version {
-    $_ = qx/which claws-mail/;
-    chomp;
-    return "" unless ($_); # not installed
+    $_ = which ('claws-mail');
+    return "" unless defined $_; # not installed
     my $res = "";
     $_ = qx/$_ -v/;
     chomp;
@@ -392,23 +380,23 @@ sub handle_selection_value {
 }
 
 sub get_rc_filename {
-    return $CONFIGDIR . $CONFIGRC;
+    return catfile ($CONFIGDIR, $CONFIGRC);
 }
 
 sub get_ac_rc_filename {
-    return $CONFIGDIR . $ACCOUNTRC;
+    return catfile ($CONFIGDIR, $ACCOUNTRC);
 }
 
 sub get_menurc_filename {
-    return $CONFIGDIR . "menurc";
+    return catfile ($CONFIGDIR, "menurc");
 }
 
 sub set_rc_filename {
     my ($fullname) = @_;
-    my @parts = split ('/', $fullname);
+    my @parts = splitpath ($fullname);
     $CONFIGRC = $parts[$#parts];
     $parts[$#parts] = '';
-    $CONFIGDIR = join ('/', @parts);
+    $CONFIGDIR = catpath (@parts);
 }
 
 sub log_message {
@@ -450,7 +438,7 @@ sub error_dialog {
     my ($emsg) = @_;
     my $markup = "<span weight=\"bold\" size=\"large\">" . $emsg . "</span>";
     my $errordlg = message_dialog (
-        $main_window, $xl::s{error_title}, $markup, 'error', [ 'gtk-cancel', 0 ]
+        $main_window, _('Clawsker error'), $markup, 'error', [ 'gtk-cancel', 0 ]
     );
     $errordlg->run;
     $errordlg->destroy;
@@ -465,13 +453,12 @@ sub claws_is_running {
 
 sub check_claws_not_running {
     return TRUE if $READONLY;
-    my $tmpdir = (defined $ENV{TMPDIR})? $ENV{TMPDIR}: '/tmp';
-    $tmpdir = '/tmp' if ($tmpdir eq '');
-    my $lockdir = "$tmpdir/claws-mail-$<";
+    my $tmpdir = File::Spec->tmpdir ();
+    my $lockdir = catfile ($tmpdir, "claws-mail-$<");
     -d $lockdir and do {
         $_ = $CONFIGDIR;
         s/\/$//;
-        my $socket = "$lockdir/" . md5_hex ($_);
+        my $socket = catfile ($lockdir, md5_hex ($_));
         -S $socket and return claws_is_running ();
     };
     return TRUE;
@@ -1922,26 +1909,16 @@ sub new_winpos_subpage_misc() {
 sub new_winpos_page() {
     my $winbook = Gtk3::Notebook->new;
     $winbook->set_tab_pos ('right');
-    $winbook->append_page (new_winpos_subpage_main,
-        Gtk3::Label->new (_('Main')));
-    $winbook->append_page (new_winpos_subpage_msgs,
-        Gtk3::Label->new (_('Message')));
-    $winbook->append_page (new_winpos_subpage_sendrecv,
-        Gtk3::Label->new (_('Send/Receive')));
-    $winbook->append_page (new_winpos_subpage_fold,
-        Gtk3::Label->new (_('Folder')));
-    $winbook->append_page (new_winpos_subpage_addrbook,
-        Gtk3::Label->new (_('Addressbook')));
-    $winbook->append_page (new_winpos_subpage_accounts,
-        Gtk3::Label->new (_('Accounts')));
-    $winbook->append_page (new_winpos_subpage_filtering,
-        Gtk3::Label->new (_('Filtering')));
-    $winbook->append_page (new_winpos_subpage_useractions,
-        Gtk3::Label->new (_('User Actions')));
-    $winbook->append_page (new_winpos_subpage_prefs,
-        Gtk3::Label->new (_('Preferences')));
-    $winbook->append_page (new_winpos_subpage_misc,
-        Gtk3::Label->new (_('Other')));
+    $winbook->append_page (&new_winpos_subpage_main, new_label (_('Main')));
+    $winbook->append_page (&new_winpos_subpage_msgs, new_label (_('Message')));
+    $winbook->append_page (&new_winpos_subpage_sendrecv, new_label (_('Send/Receive')));
+    $winbook->append_page (&new_winpos_subpage_fold, new_label (_('Folder')));
+    $winbook->append_page (&new_winpos_subpage_addrbook, new_label (_('Addressbook')));
+    $winbook->append_page (&new_winpos_subpage_accounts, new_label (_('Accounts')));
+    $winbook->append_page (&new_winpos_subpage_filtering, new_label (_('Filtering')));
+    $winbook->append_page (&new_winpos_subpage_useractions, new_label (_('User Actions')));
+    $winbook->append_page (&new_winpos_subpage_prefs, new_label (_('Preferences')));
+    $winbook->append_page (&new_winpos_subpage_misc, new_label (_('Other')));
     return $winbook;
 }
 
@@ -2096,14 +2073,6 @@ sub new_plugins_page() {
     ]);
 }
 
-use constant {
-    C_LABEL => 0,
-    C_HOTKEY => 1,
-    C_GROUP => 2,
-    C_ACCEL => 3,
-    C_ODDITY => 4,
-};
-
 sub new_hotkeys_list_label {
     my $renderer = Gtk3::CellRendererText->new ();
     $renderer->set_property('alignment' => 'left');
@@ -2204,9 +2173,7 @@ sub new_hotkeys_page() {
     foreach my $gkey (sort keys %$HOTKEYS) {
         my $group = $HOTKEYS->{$gkey};
         # group title
-        my $glabel = Gtk3::Label->new ('<b>' . $gkey . '</b>');
-        $glabel->set_use_markup (TRUE);
-        $glabel->set_alignment (0, 0.5);
+        my $glabel = new_title ($gkey);
         $glabel->set_padding (5, 1);
         $vbox->pack_start ($glabel, FALSE, FALSE, 0);
         # group key list
@@ -2344,7 +2311,6 @@ sub opt_alternate_config_dir {
     die _("Error: '{dir}' is not a directory or does not exist\n", dir => $value)
         unless -d $value;
     $CONFIGDIR = $value;
-    $CONFIGDIR .= "/" unless ($CONFIGDIR =~ /.*\/$/);
     $ALTCONFIGDIR = TRUE;
 }
 
@@ -2618,25 +2584,16 @@ sub save_preferences {
 # create notebook
 sub new_notebook {
     my $nb = Gtk3::Notebook->new;
-    #
-    $nb->append_page (new_behaviour_page (),
-        Gtk3::Label->new ($xl::s{tab_behaviour}));
-    $nb->append_page (new_colours_page (),
-        Gtk3::Label->new ($xl::s{tab_colours}));
-    $nb->append_page (new_gui_page (),
-        Gtk3::Label->new ($xl::s{tab_gui}));
-    $nb->append_page (new_other_page (),
-        Gtk3::Label->new ($xl::s{tab_other}));
-    $nb->append_page (new_winpos_page (),
-        Gtk3::Label->new ($xl::s{tab_winpos}));
-    $nb->append_page (new_accounts_page (),
-        Gtk3::Label->new ($xl::s{tab_accounts}));
-    $nb->append_page (new_plugins_page (),
-        Gtk3::Label->new ($xl::s{tab_plugins}));
-    $nb->append_page (new_hotkeys_page (),
-        Gtk3::Label->new ($xl::s{tab_hotkeys}));
-    $nb->append_page (new_info_page (),
-        Gtk3::Label->new ($xl::s{tab_info}));
+
+    $nb->append_page (&new_behaviour_page, Gtk3::Label->new (_('Behaviour')));
+    $nb->append_page (&new_colours_page, Gtk3::Label->new (_('Colours')));
+    $nb->append_page (&new_gui_page, Gtk3::Label->new (_('GUI')));
+    $nb->append_page (&new_other_page, Gtk3::Label->new (_('Other')));
+    $nb->append_page (&new_winpos_page, Gtk3::Label->new (_('Windows')));
+    $nb->append_page (&new_accounts_page, Gtk3::Label->new (_('Accounts')));
+    $nb->append_page (&new_plugins_page, Gtk3::Label->new (_('Plugins')));
+    $nb->append_page (&new_hotkeys_page, Gtk3::Label->new (_('Hotkeys')));
+    $nb->append_page (&new_info_page, Gtk3::Label->new (_('Info')));
 
     return $nb;
 }
@@ -2656,7 +2613,7 @@ sub new_about_dialog {
     $dialog->set_copyright ("Copyright © $year $holder");
     $dialog->set_license_type ('gpl-3-0');
     $dialog->set_website ($url);
-    $dialog->set_website_label ($xl::s{about_web_label});
+    $dialog->set_website_label (_("Visit Clawsker's web page"));
     # committers, by number of commits
     $dialog->set_authors ([
         $holder,
@@ -2683,6 +2640,7 @@ sub new_about_dialog {
         'Mark Chang <mark.cyj@gmail.com>',
         'M. Sulchan Darmawan <bleketux@gmail.com>',
         'Numan Demirdöğen <if.gnu.linux@gmail.com>',
+        'Pedro Albuquerque <pmra@gmx.com>',
         'Petter Adsen <petter@synth.no>',
         $holder,
         'Tristan Chabredier (wwp) <subscript@free.fr>',
@@ -2696,15 +2654,16 @@ sub new_about_dialog {
 sub exit_handler {
   my ($parent) = @_;
   if ($MODIFIED != 0 and not $READONLY) {
-    my $markup = "<span>" . $xl::s{exit_fact} . "</span>\n\n"
-        . "<span weight=\"bold\">" . $xl::s{exit_question} . "</span>\n";
+    my $markup = "<span>" . _('There are unapplied modifications.')
+        . "</span>\n\n<span weight=\"bold\">"
+        . _('Do you really want to quit?') . "</span>\n";
     my $dialog = message_dialog (
-        $parent, $xl::s{exit_title}, $markup, 'question',
+        $parent, _('Clawsker warning'), $markup, 'question',
         [ 'gtk-no', 1, 'gtk-yes', 0 ]
     );
     my $resp = $dialog->run;
     $dialog->hide;
-    return TRUE if ($resp == 1);
+    return TRUE if $resp;
   }
   Gtk3->main_quit;
 }
@@ -2737,13 +2696,13 @@ sub get_app_icons {
     return \@APPICONS if (@APPICONS);
     my @names;
     if (-d $DATADIR) { # installed
-        my $dir = $DATADIR . '/icons/hicolor';
+        my $dir = catdir ($DATADIR, 'icons', 'hicolor');
         @names = map {
-            join ('/', ($dir, $_ . 'x' . $_, 'apps', $NAME . '.png'))
+            catfile ($dir, $_ . 'x' . $_, 'apps', $NAME . '.png')
         } (48, 64, 128);
     } else { # unpacked tarball or git clone
         @names = map {
-            join ('/', ('./icons', $NAME . '-' . $_ . '.png'));
+            catfile ('.', 'icons', $NAME . '-' . $_ . '.png');
         } (48, 64, 128);
     }
     foreach (@names) {
@@ -2775,7 +2734,7 @@ $box->pack_start (new_notebook (), TRUE, TRUE, 0);
 $box->pack_end (new_button_box ($main_window, $about), FALSE, FALSE, 0);
 $main_window->signal_connect (delete_event => sub { exit_handler($main_window) });
 $main_window->signal_connect (key_press_event => \&escape_key_handler);
-$main_window->set_title ($xl::s{win_title});
+$main_window->set_title (_('Claws Mail Hidden Preferences'));
 $main_window->set_icon_list (get_app_icons ());
 $main_window->add ($box);
 $main_window->show_all;