From 913ae97ad315e6689413320eb04107a1ff8e3621 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Sat, 3 Aug 2019 14:02:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=90=20Fix=20invitations=20date=20local?= =?UTF-8?q?ization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpanfile | 2 +- cpanfile.snapshot | 1 - lib/Lufi/Plugin/Helpers.pm | 43 +++++++++++++++++++ themes/default/lib/Lufi/I18N/ar.po | 10 ++--- themes/default/lib/Lufi/I18N/ca.po | 12 +++--- themes/default/lib/Lufi/I18N/de.po | 10 ++--- themes/default/lib/Lufi/I18N/en.po | 12 +++--- themes/default/lib/Lufi/I18N/fr.po | 14 +++--- themes/default/lib/Lufi/I18N/fr_FR.po | 12 +++--- themes/default/lib/Lufi/I18N/it.po | 10 ++--- themes/default/lib/Lufi/I18N/lufi.pot | 10 ++--- themes/default/lib/Lufi/I18N/nl.po | 10 ++--- themes/default/lib/Lufi/I18N/oc.po | 20 ++++----- themes/default/lib/Lufi/I18N/pt.po | 10 ++--- .../invitations/my_invitations.html.ep | 8 ++-- .../notification_files_sent.mail.ep | 6 +-- 16 files changed, 116 insertions(+), 74 deletions(-) diff --git a/cpanfile b/cpanfile index 5c3173b..bf8f1ee 100644 --- a/cpanfile +++ b/cpanfile @@ -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'; diff --git a/cpanfile.snapshot b/cpanfile.snapshot index 330d03d..bfe4c0a 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -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 diff --git a/lib/Lufi/Plugin/Helpers.pm b/lib/Lufi/Plugin/Helpers.pm index 99b1012..0d7316c 100644 --- a/lib/Lufi/Plugin/Helpers.pm +++ b/lib/Lufi/Plugin/Helpers.pm @@ -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; diff --git a/themes/default/lib/Lufi/I18N/ar.po b/themes/default/lib/Lufi/I18N/ar.po index 779b553..d4d88d7 100644 --- a/themes/default/lib/Lufi/I18N/ar.po +++ b/themes/default/lib/Lufi/I18N/ar.po @@ -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:" diff --git a/themes/default/lib/Lufi/I18N/ca.po b/themes/default/lib/Lufi/I18N/ca.po index bc23741..200a7d6 100644 --- a/themes/default/lib/Lufi/I18N/ca.po +++ b/themes/default/lib/Lufi/I18N/ca.po @@ -4,7 +4,7 @@ # FIRST AUTHOR , YEAR. # xd , 2017. # Luc Didry , 2018. #zanata -# Quentí , 2018. #zanata +# Quentí, 2018. #zanata # Luc Didry , 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:" diff --git a/themes/default/lib/Lufi/I18N/de.po b/themes/default/lib/Lufi/I18N/de.po index f3e96d3..41dc120 100644 --- a/themes/default/lib/Lufi/I18N/de.po +++ b/themes/default/lib/Lufi/I18N/de.po @@ -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:" diff --git a/themes/default/lib/Lufi/I18N/en.po b/themes/default/lib/Lufi/I18N/en.po index 4bfb012..eae895f 100644 --- a/themes/default/lib/Lufi/I18N/en.po +++ b/themes/default/lib/Lufi/I18N/en.po @@ -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 \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:" diff --git a/themes/default/lib/Lufi/I18N/fr.po b/themes/default/lib/Lufi/I18N/fr.po index 626647f..3eec7c9 100644 --- a/themes/default/lib/Lufi/I18N/fr.po +++ b/themes/default/lib/Lufi/I18N/fr.po @@ -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 \n" +"Last-Translator: Luc Didry \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:" diff --git a/themes/default/lib/Lufi/I18N/fr_FR.po b/themes/default/lib/Lufi/I18N/fr_FR.po index a739a4f..29b4558 100644 --- a/themes/default/lib/Lufi/I18N/fr_FR.po +++ b/themes/default/lib/Lufi/I18N/fr_FR.po @@ -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 \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:" diff --git a/themes/default/lib/Lufi/I18N/it.po b/themes/default/lib/Lufi/I18N/it.po index 7898b00..7aaa99c 100644 --- a/themes/default/lib/Lufi/I18N/it.po +++ b/themes/default/lib/Lufi/I18N/it.po @@ -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:" diff --git a/themes/default/lib/Lufi/I18N/lufi.pot b/themes/default/lib/Lufi/I18N/lufi.pot index f358d00..4a17dc8 100644 --- a/themes/default/lib/Lufi/I18N/lufi.pot +++ b/themes/default/lib/Lufi/I18N/lufi.pot @@ -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:" diff --git a/themes/default/lib/Lufi/I18N/nl.po b/themes/default/lib/Lufi/I18N/nl.po index 8407a62..4b7997c 100644 --- a/themes/default/lib/Lufi/I18N/nl.po +++ b/themes/default/lib/Lufi/I18N/nl.po @@ -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:" diff --git a/themes/default/lib/Lufi/I18N/oc.po b/themes/default/lib/Lufi/I18N/oc.po index 61a1226..66b36a8 100644 --- a/themes/default/lib/Lufi/I18N/oc.po +++ b/themes/default/lib/Lufi/I18N/oc.po @@ -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í \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 qualqu’un" #: themes/default/templates/partial/render.js.ep:6 msgid "" diff --git a/themes/default/lib/Lufi/I18N/pt.po b/themes/default/lib/Lufi/I18N/pt.po index 99a0788..f18f879 100644 --- a/themes/default/lib/Lufi/I18N/pt.po +++ b/themes/default/lib/Lufi/I18N/pt.po @@ -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:" diff --git a/themes/default/templates/invitations/my_invitations.html.ep b/themes/default/templates/invitations/my_invitations.html.ep index ff9da9c..9cac6d0 100644 --- a/themes/default/templates/invitations/my_invitations.html.ep +++ b/themes/default/templates/invitations/my_invitations.html.ep @@ -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();

<%= l('My invitations') %>


@@ -48,9 +48,9 @@ <%= $e->guest_mail %> <%= url_for('guest', token => $e->token)->to_abs %> - <%= time2str(l('%A %d %B %Y at %T'), $e->created_at) %> - <%= time2str(l('%A %d %B %Y at %T'), $e->expire_at) %> - <%= time2str(l('%A %d %B %Y at %T'), $e->files_sent_at) if $e->files_sent_at %> + <%= $lang->time2str(l('%A %d %B %Y at %T'), $e->created_at) %> + <%= $lang->time2str(l('%A %d %B %Y at %T'), $e->expire_at) %> + <%= $lang->time2str(l('%A %d %B %Y at %T'), $e->files_sent_at) if $e->files_sent_at %> % if ($e->files) { 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} % });