Bug 11263: do not use system locales settings for subscriptions
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 19 Nov 2013 13:21:38 +0000 (14:21 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 05:00:42 +0000 (05:00 +0000)
The locales list for subscriptions should not be retrieved from the
locales of the system.
This patch retrieves the locales list from the Koha DB (in the same way
as pref language and opaclanguages).

Test plan:
Edit a subscription (or a numbering pattern) and verify the list of
languages is the same as languages available in Koha.
Note: with this patch we loose the saeson translation, it is
normal. See report linked.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described. No koha-qa errors.

New locale is retrieved from installed languages.
I wonder if that list can be restricted to
'enabled' ones (parsing syspref language value).

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes QA script and all tests.
Works according to description.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-numberpatterns.tt
serials/subscription-add.pl
serials/subscription-numberpatterns.pl

index 2923c97..62da614 100644 (file)
@@ -693,14 +693,14 @@ $(document).ready(function() {
                                         <select id="locale" name="locale">
                                             <option value=""></option>
                                             [% FOREACH l IN locales %]
-                                                [% IF l == locale %]
-                                                    <option value="[% l %]" selected="selected">[% l %]</option>
+                                                [% IF l.language == locale %]
+                                                    <option value="[% l.language %]" selected="selected">[% l.description %]</option>
                                                 [% ELSE %]
-                                                    <option value="[% l %]">[% l %]</option>
+                                                    <option value="[% l.language %]">[% l.description %]</option>
                                                 [% END %]
                                             [% END %]
                                         </select>
-                                        <span class="hint">If empty, system locale is used</span>
+                                        <span class="hint">If empty, English is used</span>
                                     </li>
                                     <li id="more_options">
                                         <table id="moreoptionst">
index 953882f..8c8c28c 100644 (file)
@@ -231,7 +231,7 @@ function show_blocking_subs() {
                         <option value="[% locale %]">[% locale %]</option>
                       [% END %]
                     </select>
-                  <span class="hint">If empty, system locale is used</span>
+                  <span class="hint">If empty, English is used</span>
                 </li>
               </ol>
               <table>
index f609102..c6edab4 100755 (executable)
@@ -213,15 +213,14 @@ if ($op eq 'addsubscription') {
     }
     $template->param(numberpatterns => \@numberpatternloop);
 
-    # Get installed locales
-    # FIXME this will not work with all environments.
-    # If call to locale fails, @locales will be an empty array, which is fine.
-    my @locales = map {
-        chomp;
-        # we don't want POSIX and C locales
-        /^C|^POSIX$/ ? () : $_
-    } `locale -a`;
-    $template->param(locales => \@locales);
+    my $languages = [ map {
+        {
+            language => $_->{language},
+            description => $_->{native_description} || $_->{language}
+        }
+    } @{ C4::Languages::getTranslatedLanguages() } ];
+
+    $template->param( locales => $languages );
 
     output_html_with_http_headers $query, $cookie, $template->output;
 }
index c2a9800..065ab01 100755 (executable)
@@ -105,17 +105,18 @@ if($op && ($op eq 'new' || $op eq 'modify')) {
     my @frequencies = GetSubscriptionFrequencies();
     my @subtypes;
     push @subtypes, { value => $_ } for (qw/ issues weeks months /);
-    my @locales = map {
-        chomp;
-        /^C|^POSIX$/ ? () : $_
-    } `locale -a`;
+    my $languages = [ map {
+        {
+            language => $_->{language},
+            description => $_->{native_description} || $_->{language}
+        }
+    } @{ C4::Languages::getTranslatedLanguages() } ];
 
     $template->param(
         $op => 1,
         frequencies_loop => \@frequencies,
         subtypes_loop => \@subtypes,
-        locales => \@locales,
-        DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
+        locales => $languages,
     );
     output_html_with_http_headers $input, $cookie, $template->output;
     exit;