diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-05-09 00:51:36 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-05-09 00:51:36 +0200 |
commit | 0583b0115114ba9357789d3aa153c472eb7071ab (patch) | |
tree | 16885616efed9d704639259881f58bd6748a1d7b /lib/JWebmail/I18N.pm | |
parent | 77992072b7963d9a96c11a3913f553c820cc21da (diff) |
improvements to i18n development experience
Diffstat (limited to 'lib/JWebmail/I18N.pm')
-rw-r--r-- | lib/JWebmail/I18N.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/JWebmail/I18N.pm b/lib/JWebmail/I18N.pm index 576c413..190f4be 100644 --- a/lib/JWebmail/I18N.pm +++ b/lib/JWebmail/I18N.pm @@ -1,8 +1,40 @@ package JWebmail::I18N; +use v5.22; +use warnings; +use utf8; + use parent 'Locale::Maketext'; +sub init { + my $self = shift; + $self->SUPER::init(@_); + + $self->fail_with('log_on_failure'); +} + +sub fallback_languages { return (); } + +sub log_on_failure { + my $self = shift; + my $prase = shift; + $self->logger->("missing translation for @{[$self->language_tag]}:'$prase'"); + $self->failure_handler_auto($prase, @_); +} + +sub logger { + my $self = shift; + if (@_) { + $self->{_jwm_logger} = $_[0]; + return $self; + } + else { + return $self->{_jwm_logger}; + } +} + + 1 __END__ |