Bug 42727: Sort using the order from the staff syspref

The main goal of the previous patch was to prevent the randomness,
the languages were displayed by code.

The languages in the footer are the languages enabled for the staff interface.

This patch suggests to use the order of the syspref, and append the
languages not enabled at the end of the list.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-06-18 12:07:26 +02:00 committed by Pedro Amorim
parent a098d97b5a
commit 6e162e4c10
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 6 additions and 4 deletions

View File

@ -34,7 +34,7 @@ BEGIN {
use Carp qw( carp ); use Carp qw( carp );
use CGI; use CGI;
use List::MoreUtils qw( any ); use List::MoreUtils qw( any uniq );
use C4::Context; use C4::Context;
use Koha::Caches; use Koha::Caches;
use Koha::Cache::Memory::Lite; use Koha::Cache::Memory::Lite;
@ -123,6 +123,10 @@ sub getTranslatedLanguages {
} elsif ( $interface eq 'opac' ) { } elsif ( $interface eq 'opac' ) {
@enabled_languages = split ",", C4::Context->preference('OPACLanguages'); @enabled_languages = split ",", C4::Context->preference('OPACLanguages');
} }
} else {
@enabled_languages = split ",",
join( ',', C4::Context->preference( 'StaffInterfaceLanguages', C4::Context->preference('OPACLanguages') ) );
@enabled_languages = uniq @enabled_languages;
} }
my $cache = Koha::Caches->get_instance; my $cache = Koha::Caches->get_instance;
@ -152,9 +156,7 @@ sub getTranslatedLanguages {
$htdocs = C4::Context->config('opachtdocs'); $htdocs = C4::Context->config('opachtdocs');
push @languages, _get_opac_language_dirs($htdocs); push @languages, _get_opac_language_dirs($htdocs);
my %seen; @languages = uniq @languages;
$seen{$_}++ for @languages;
@languages = keys %seen;
} }
return _build_languages_arrayref( \@languages, $current_language, \@enabled_languages ); return _build_languages_arrayref( \@languages, $current_language, \@enabled_languages );
} }