Bugzilla – Attachment 23338 Details for
Bug 11262
Don't require hardcoded translations for seasonal numbering pattern to work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11262 - Don't require hardcoded translations for seasonal numbering pattern to work
Bug-11262---Dont-require-hardcoded-translations-fo.patch (text/plain), 8.54 KB, created by
Kyle M Hall (khall)
on 2013-12-06 12:56:42 UTC
(
hide
)
Description:
Bug 11262 - Don't require hardcoded translations for seasonal numbering pattern to work
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-12-06 12:56:42 UTC
Size:
8.54 KB
patch
obsolete
>From 26ad9d8d7945634750c9a236b82abc34a1f6bbee Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 19 Nov 2013 14:30:21 +0100 >Subject: [PATCH] Bug 11262 - Don't require hardcoded translations for seasonal numbering pattern to work > >This patch removes the use of POSIX::strftime which is based on the >locales of the system. >The DateTime module translates month and day name with success, without >any locale installed. >For the saesons, I use the way used in Koha: write the word in >templates. On this way the translate script will match them and allow >translators to translate them. > >This patch adds a regression: the season names are not translated >following the locale selected. >This could be done when bug 8044 will be pushed. > >Test plan: >0/ Update your po files and translate the season name. >1/ Create a numbering pattern using season. >example: >Name: Seasonal >Numbering formula: {X} >X: Season, Add=1, Every=1, Set back to 0 when more than 3, formatting >"name of season" >And test the prediction pattern with: >frequency: 1/3 month >First issue : 2013-09-21 >length: 12 months >X begins with 2 (21th Septembre is Fall) >2/ Click on the test pattern button, you should get: >Fall 21/09/2013 >Winter 21/12/2013 >Spring 21/03/2014 >Summer 21/06/2014 > >Change the locale and verify the season names are *not* translated. >Change the Koha language and verify the season names are translated. > >3/ Create a numbering pattern using day or month name. >example: >Name: day >Numbering formula: {X} >X: day, Add=1, Every=1, Set back to 0 when more than 6, formatting "name >of day" >Frequency: 1/day >First issue: 2013-11-18 >length: 1 month >X begins with 0 >You should get: >Monday 18/11/2013 >Tuesday 19/11/2013 >Wednesday 20/11/2013 >[...] >Sunday 15/12/2013 >Monday 16/12/2013 >Tuesday 17/12/2013 > >change the locale and verify the day names are translated. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Work as described. No koha-qa errors > >Tested on top of Bug 11265 and Bug 11263, >and solved merge conflict > >Updating PO file gives seasons to translate. >Tested using seasons, day and month > >Only note is different behavior >1) To use seasons you need to use staff in desired language >2) To use day and month only need to select locale > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >No regressions found. Passes koha-qa.pl, t and xt >--- > C4/Serials.pm | 48 +++++++++----------- > .../prog/en/modules/serials/serials-collection.tt | 12 +++++- > .../en/modules/serials/showpredictionpattern.tt | 14 +++++- > .../modules/serials/subscription-numberpatterns.tt | 2 +- > 4 files changed, 47 insertions(+), 29 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 6d188e7..59babbf 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -23,8 +23,9 @@ use Modern::Perl; > use C4::Auth qw(haspermission); > use C4::Context; > use C4::Dates qw(format_date format_date_in_iso); >+use DateTime; > use Date::Calc qw(:all); >-use POSIX qw(strftime setlocale LC_TIME); >+use POSIX qw(strftime); > use C4::Biblio; > use C4::Log; # logaction > use C4::Debug; >@@ -2665,44 +2666,39 @@ num_type can take : > sub _numeration { > my ($value, $num_type, $locale) = @_; > $value ||= 0; >- my $initlocale = setlocale(LC_TIME); >- if($locale and $locale ne $initlocale) { >- $locale = setlocale(LC_TIME, $locale); >- } >- $locale ||= $initlocale; >- my $string; > $num_type //= ''; >+ $locale ||= 'en'; >+ my $string; > given ($num_type) { > when (/^dayname$/) { >- $value = $value % 7; >- $string = POSIX::strftime("%A",0,0,0,0,0,0,$value); >+ # 1970-06-01 was a monday >+ $value = $value % 7; >+ my $dt = DateTime->new( >+ year => 1970, >+ month => 6, >+ day => $value + 1, >+ locale => $locale, >+ ); >+ $string = $dt->strftime("%A"); > } > when (/^monthname$/) { >- $value = $value % 12; >- $string = POSIX::strftime("%B",0,0,0,1,$value,0,0,0,0); >+ $value = $value % 12; >+ my $dt = DateTime->new( >+ year => 1970, >+ month => $value + 1, >+ locale => $locale, >+ ); >+ $string = $dt->strftime("%B"); > } > when (/^season$/) { >- my $seasonlocale = ($locale) >- ? (substr $locale,0,2) >- : "en"; >- my %seasons=( >- "en" => >- [qw(Spring Summer Fall Winter)], >- "fr"=> >- [qw(Printemps Ãté Automne Hiver)], >- ); >+ my @seasons= qw( Spring Summer Fall Winter ); > $value = $value % 4; >- $string = ($seasons{$seasonlocale}) >- ? $seasons{$seasonlocale}->[$value] >- : $seasons{'en'}->[$value]; >+ $string = $seasons[$value]; > } > default { > $string = $value; > } > } >- if($locale ne $initlocale) { >- setlocale(LC_TIME, $initlocale); >- } > return $string; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >index 060ecaf..2eb15d5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >@@ -250,7 +250,17 @@ $(document).ready(function() { > <span title="[% serial.planneddate %]">[% serial.planneddate | $KohaDates %]</span> > </td> > <td> >- [% serial.serialseq %] >+ [% IF ( matches = serial.serialseq.match('Spring(.*)') ) %] >+ Spring[% matches.join("") %] >+ [% ELSIF ( matches = serial.serialseq.match('Summer(.*)') ) %] >+ Summer[% matches.join("") %] >+ [% ELSIF ( matches = serial.serialseq.match('Fall(.*)') ) %] >+ Fall[% matches.join("") %] >+ [% ELSIF ( matches = serial.serialseq.match('Winter(.*)') ) %] >+ Winter[% matches.join("") %] >+ [% ELSE %] >+ [% serial.serialseq %] >+ [% END %] > </td> > <td> > [% IF ( serial.status1 ) %]Expected[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >index 5a12652..9a586dc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/showpredictionpattern.tt >@@ -56,7 +56,19 @@ > <tbody> > [% FOREACH prediction IN predictions_loop %] > <tr> >- <td>[% prediction.number %]</td> >+ <td> >+ [% IF ( matches = prediction.number.match('Spring(.*)') ) %] >+ Spring[% matches.join("") %] >+ [% ELSIF ( matches = prediction.number.match('Summer(.*)') ) %] >+ Summer[% matches.join("") %] >+ [% ELSIF ( matches = prediction.number.match('Fall(.*)') ) %] >+ Fall[% matches.join("") %] >+ [% ELSIF ( matches = prediction.number.match('Winter(.*)') ) %] >+ Winter[% matches.join("") %] >+ [% ELSE %] >+ [% prediction.number %] >+ [% END %] >+ </td> > <td> > [% IF (prediction.publicationdate) %] > [% prediction.publicationdate | $KohaDates %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt >index 686cdc8..81e5ea7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt >@@ -228,7 +228,7 @@ function show_blocking_subs() { > <select id="locale" name="locale"> > <option value=""></option> > [% FOREACH locale IN locales %] >- <option value="[% locale %]">[% locale %]</option> >+ <option value="[% locale.language %]">[% locale.description %]</option> > [% END %] > </select> > <span class="hint">If empty, system locale is used</span> >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11262
:
23035
|
23129
|
23135
|
23338
|
23473