summaryrefslogtreecommitdiff
path: root/lib/JWebmail/Plugin
diff options
context:
space:
mode:
Diffstat (limited to 'lib/JWebmail/Plugin')
-rw-r--r--lib/JWebmail/Plugin/I18N2/Maketext.pm19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/JWebmail/Plugin/I18N2/Maketext.pm b/lib/JWebmail/Plugin/I18N2/Maketext.pm
index ef3b08d..1046a99 100644
--- a/lib/JWebmail/Plugin/I18N2/Maketext.pm
+++ b/lib/JWebmail/Plugin/I18N2/Maketext.pm
@@ -1,12 +1,12 @@
package JWebmail::Plugin::I18N2::Maketext;
-use v5.22;
+use v5.24;
use warnings;
use utf8;
use JWebmail::I18N;
-use File::Basename 'fileparse';
+use Mojo::File qw(path curfile);
use Role::Tiny::With;
with 'JWebmail::Plugin::I18N2::Role';
@@ -16,19 +16,10 @@ sub new {
my $class = shift;
my $conf = @_ == 1 ? shift : {@_};
- my $lexica = $conf->{directory};
+ my $lexica = curfile->dirname->child('..', '..', 'I18N');
- my @languages = keys %{$conf->{languages} // {}};
-
- unless (@languages) {
- use autodie;
-
- opendir(my $dh, $lexica);
- my @res = grep { /\.pm$/ && -f "$lexica/$_" } readdir $dh;
- closedir($dh);
- @languages = map { scalar fileparse $_, '.pm' } @res;
- @languages = map { my ($l, $c) = split '_', $_, 2; $c ? "$l-\U$c" : $l } @languages;
- }
+ my $res = $lexica->list()->map('basename', '.pm');
+ my @languages = map { my ($l, $c) = split '_', $_, 2; $c ? "$l-\U$c" : $l } @$res;
if (my $dl = $conf->{default_language}) { push @languages, $dl; };
my $self = {};