Skip to content
Snippets Groups Projects
Commit 723e4fbd authored by Guillaume ROUSSE's avatar Guillaume ROUSSE
Browse files

allow custom translation files

parent 81eba94c
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ use utf8; ...@@ -6,6 +6,7 @@ use utf8;
use lib qw(@modulesdir@); use lib qw(@modulesdir@);
use Config::Tiny; use Config::Tiny;
use File::Basename;
use AccountManager::App; use AccountManager::App;
...@@ -16,8 +17,11 @@ if (!$configuration) { ...@@ -16,8 +17,11 @@ if (!$configuration) {
die Config::Tiny->errstr() . "\n"; die Config::Tiny->errstr() . "\n";
} }
my $configuration_directory = dirname($configuration_file);
my $app = AccountManager::App->new( my $app = AccountManager::App->new(
configuration => $configuration configuration => $configuration,
custom_l10n => sprintf("%s/l10n", $configuration_directory)
); );
$app->run(); $app->run();
......
...@@ -87,6 +87,7 @@ sub new { ...@@ -87,6 +87,7 @@ sub new {
} }
); );
} }
$self->{lh}->load_custom_lexicon($args{custom_l10n});
if (!$self->{configuration}->{mailer}) { if (!$self->{configuration}->{mailer}) {
$self->{logger}->fatal( $self->{logger}->fatal(
......
...@@ -4,5 +4,20 @@ use strict; ...@@ -4,5 +4,20 @@ use strict;
use warnings; use warnings;
use base 'Locale::Maketext'; use base 'Locale::Maketext';
use Locale::Maketext::Lexicon::Gettext;
sub load_custom_lexicon {
my ($self, $directory) = @_;
my $language = $self->language_tag();
my $lexicon_file = sprintf("%s/%s.po", $directory , $language);
return unless -f $lexicon_file;
Locale::Maketext::Lexicon->import({
$language => [Gettext => $lexicon_file],
_decode => 1,
});
}
1; 1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment