From 0583b0115114ba9357789d3aa153c472eb7071ab Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Mon, 9 May 2022 00:51:36 +0200 Subject: improvements to i18n development experience --- lib/JWebmail/I18N.pm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/JWebmail/I18N.pm') 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__ -- cgit v1.2.3