From 544d48b07f340b97e59d5a9dd8ee2f9258b5033e Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Tue, 19 Nov 2013 14:21:38 +0100
Subject: [PATCH] Bug 11263: locale setting is not user friendly
The locales list for subscriptions should not be retrieve 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.
---
.../prog/en/modules/serials/subscription-add.tt | 8 ++++----
.../en/modules/serials/subscription-numberpatterns.tt | 2 +-
serials/subscription-add.pl | 17 ++++++++---------
serials/subscription-numberpatterns.pl | 13 +++++++------
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
index 713b3b1..57c0b59 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
@@ -707,14 +707,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">
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..932b54f 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
@@ -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>
diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl
index 552b65b..2761dfc 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -215,15 +215,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;
}
diff --git a/serials/subscription-numberpatterns.pl b/serials/subscription-numberpatterns.pl
index c2a9800..065ab01 100755
--- a/serials/subscription-numberpatterns.pl
+++ b/serials/subscription-numberpatterns.pl
@@ -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;
--
1.7.10.4