From 926ec7a6b85e6e3f7335a8c5ddcccd51937ee2d8 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Fri, 8 Sep 2023 23:32:10 +0200 Subject: added a build configuration step --- lib/JWebmail/Plugin/I18N2/Maketext.pm | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'lib/JWebmail/Plugin/I18N2') 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 = {}; -- cgit v1.2.3