🌐 Fix invitations date localization

This commit is contained in:
Luc Didry 2019-08-03 14:02:10 +02:00
parent 5c68596a10
commit 913ae97ad3
No known key found for this signature in database
GPG Key ID: EA868E12D0257E3C
16 changed files with 116 additions and 74 deletions

View File

@ -37,7 +37,7 @@ feature 'test' => sub {
feature 'ldap', 'LDAP authentication support' => sub {
requires 'Net::LDAP';
requires 'Mojolicious::Plugin::Authentication';
requires 'Date::Format';
requires 'Date::Language';
};
feature 'htpasswd', 'Htpasswd authentication support' => sub {
requires 'Apache::Htpasswd';

View File

@ -1989,7 +1989,6 @@ DISTRIBUTIONS
requirements:
Authen::SASL 2.00
Convert::ASN1 0.2
Digest::HMAC_MD5 0
Digest::MD5 0
ExtUtils::MakeMaker 6.59
File::Basename 0

View File

@ -3,6 +3,7 @@ package Lufi::Plugin::Helpers;
use Mojo::Base 'Mojolicious::Plugin';
use Lufi::DB::File;
use Lufi::DB::Invitation;
use Date::Language;
sub register {
my ($self, $app) = @_;
@ -67,6 +68,7 @@ sub register {
$app->helper(stop_upload => \&_stop_upload);
$app->helper(create_invitation_token => \&_create_invitation_token);
$app->helper(is_guest => \&_is_guest);
$app->helper(get_date_lang => \&_get_date_lang);
}
sub _pg {
@ -187,4 +189,45 @@ sub _is_guest {
return 0;
}
my %date_langs = (
aa => 'Afar',
am => 'Amharic',
pt => 'Brazilian',
bg => 'Bulgarian',
zh => 'Chinese',
cs => 'Czech',
da => 'Danish',
nl => 'Dutch',
fi => 'Finnish',
en => 'English',
fr => 'French',
de => 'German',
el => 'Greek',
hu => 'Hungarian',
is => 'Icelandic',
it => 'Italian',
nn => 'Norwegian',
om => 'Oromo',
ro => 'Romanian',
ru => 'Russian',
so => 'Somali',
es => 'Spanish',
sv => 'Swedish',
ti => 'Tigrinya',
tk => 'Turkish',
);
sub _get_date_lang {
my $c = shift;
my $l = $c->languages();
return Date::Language->new($date_langs{$l}) if $date_langs{$l};
$l =~ s/^(..).*/$1/;
return Date::Language->new($date_langs{$l}) if $date_langs{$l};
return Date::Language->new('English');
}
1;

View File

@ -20,11 +20,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 أيام"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -35,6 +30,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -4,7 +4,7 @@
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# xd <xdrudis@tinet.cat>, 2017.
# Luc Didry <luc@framasoft.org>, 2018. #zanata
# Quentí <quentinantonin@free.fr>, 2018. #zanata
# Quentí, 2018. #zanata
# Luc Didry <luc@framasoft.org>, 2019. #zanata
msgid ""
msgstr ""
@ -26,11 +26,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 dies"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -41,6 +36,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -20,11 +20,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 Tag"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -35,6 +30,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -7,7 +7,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2019-08-03 11:10+0000\n"
"PO-Revision-Date: 2019-08-03 11:38+0000\n"
"Last-Translator: Luc Didry <luc@framasoft.org>\n"
"Language-Team: English\n"
"Language: en\n"
@ -20,11 +20,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 days"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr "%1 have send you files"
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -35,6 +30,11 @@ msgstr "%1 invites you to send him/her files"
msgid "%1 invites you to send him/her files through Lufi."
msgstr "%1 invites you to send him/her files through Lufi."
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr "%1 sent you files"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -11,10 +11,10 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2019-08-03 10:50+0000\n"
"PO-Revision-Date: 2019-08-03 11:38+0000\n"
"Language-Team: \n"
"X-Generator: Zanata 4.6.2\n"
"Last-Translator: Copied by Zanata <copied-by-zanata@zanata.org>\n"
"Last-Translator: Luc Didry <luc@framasoft.org>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr\n"
@ -24,11 +24,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 jours"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr "%1 vous a envoyé des fichiers"
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -39,6 +34,11 @@ msgstr "%1 vous invite à lui envoyer des fichiers"
msgid "%1 invites you to send him/her files through Lufi."
msgstr "%1 vous invite à lui envoyer des fichiers via Lufi."
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr "%1 vous a envoyé des fichiers"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -11,7 +11,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2019-08-03 10:48+0000\n"
"PO-Revision-Date: 2019-08-03 11:38+0000\n"
"Language-Team: \n"
"X-Generator: Zanata 4.6.2\n"
"Last-Translator: Luc Didry <luc@framasoft.org>\n"
@ -24,11 +24,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 jours"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr "%1 vous a envoyé des fichiers"
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -39,6 +34,11 @@ msgstr "%1 vous invite à lui envoyer des fichiers"
msgid "%1 invites you to send him/her files through Lufi."
msgstr "%1 vous invite à lui envoyer des fichiers via Lufi."
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr "%1 vous a envoyé des fichiers"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -24,11 +24,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 giorni"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -39,6 +34,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -21,11 +21,6 @@ msgstr ""
msgid "%1 days"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -36,6 +31,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -20,11 +20,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 dagen"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -35,6 +30,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -14,8 +14,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2019-04-21 05:48+0000\n"
"Last-Translator: Quentí <quentinantonin@free.fr>\n"
"PO-Revision-Date: 2019-08-03 11:38+0000\n"
"Last-Translator: Quentí\n"
"Language-Team: Tot en òc (totenoc.eu)\n"
"Language: oc\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
@ -27,25 +27,25 @@ msgstr ""
msgid "%1 days"
msgstr "%1 jorns"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
msgstr ""
msgstr "%1 vos convida a li mandar de fichièrs"
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:6
msgid "%1 invites you to send him/her files through Lufi."
msgstr "%1 vos convida a li mandar de fichièrs per Lufi"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"
msgstr ""
msgstr "%1 utilizèt vòstra invitacion per vos mandar de fichièrs :"
#: lib/Lufi/Controller/Invitation.pm:159 lib/Lufi/Controller/Invitation.pm:84 themes/default/templates/invitations/my_invitations.html.ep:51 themes/default/templates/invitations/my_invitations.html.ep:52 themes/default/templates/invitations/my_invitations.html.ep:53 themes/default/templates/invitations/notification_files_sent.mail.ep:12
msgid "%A %d %B %Y at %T"
@ -419,7 +419,7 @@ msgstr ""
#: themes/default/templates/invitations/invite.html.ep:27 themes/default/templates/layouts/default.html.ep:36 themes/default/templates/layouts/default.html.ep:69
msgid "Invite a guest"
msgstr ""
msgstr "Convidar qualquun"
#: themes/default/templates/partial/render.js.ep:6
msgid ""

View File

@ -25,11 +25,6 @@ msgstr ""
msgid "%1 days"
msgstr "%1 dias"
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 have send you files"
msgstr ""
#. (stash('ldap_user')
#: themes/default/templates/invitations/invite.mail.ep:2
msgid "%1 invites you to send him/her files"
@ -40,6 +35,11 @@ msgstr ""
msgid "%1 invites you to send him/her files through Lufi."
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:4
msgid "%1 sent you files"
msgstr ""
#. (stash('invitation')
#: themes/default/templates/invitations/notification_files_sent.mail.ep:8
msgid "%1 used your invitation to send you files:"

View File

@ -1,6 +1,6 @@
% # vim:set sw=4 ts=4 sts=4 ft=html.epl expandtab:
% use Number::Bytes::Human qw(format_bytes);
% use Date::Format;
% my $lang = $self->get_date_lang();
<h2><%= l('My invitations') %></h2>
<hr>
@ -48,9 +48,9 @@
</td>
<td><%= $e->guest_mail %></td>
<td><%= url_for('guest', token => $e->token)->to_abs %></td>
<td><%= time2str(l('%A %d %B %Y at %T'), $e->created_at) %></td>
<td id="expire-<%= $e->token %>"><%= time2str(l('%A %d %B %Y at %T'), $e->expire_at) %></td>
<td><%= time2str(l('%A %d %B %Y at %T'), $e->files_sent_at) if $e->files_sent_at %></td>
<td><%= $lang->time2str(l('%A %d %B %Y at %T'), $e->created_at) %></td>
<td id="expire-<%= $e->token %>"><%= $lang->time2str(l('%A %d %B %Y at %T'), $e->expire_at) %></td>
<td><%= $lang->time2str(l('%A %d %B %Y at %T'), $e->files_sent_at) if $e->files_sent_at %></td>
<td>
% if ($e->files) {
<a href="#files-info"

View File

@ -1,7 +1,7 @@
% # vim:set sw=4 ts=4 sts=4 ft=mail.epl expandtab:
% use Number::Bytes::Human qw(format_bytes);
% use Date::Format;
% stash subject => l('%1 have send you files', stash('invitation')->guest_mail);
% my $lang = $self->get_date_lang();
% stash subject => l('%1 sent you files', stash('invitation')->guest_mail);
%= l('Hello %1,', ucfirst(stash('invitation')->ldap_user))
@ -9,7 +9,7 @@
% stash('files')->each(sub {
% my ($e, $num) = @_;
%= l('— %1 (%2), that will expire on %3', $e->{name}, format_bytes($e->{size}), time2str(l('%A %d %B %Y at %T'), $e->{created_at} + $e->{delay} * 86400))
%= l('— %1 (%2), that will expire on %3', $e->{name}, format_bytes($e->{size}), $lang->time2str(l('%A %d %B %Y at %T'), $e->{created_at} + $e->{delay} * 86400))
%= ' '.$e->{url}
% });