From dd1c90cd97dd4e2cc57c74fb1299c1bb109c9077 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 22 May 2020 16:45:02 +0200 Subject: [PATCH] Bug 25517: Look in all possible places for MO files On a 'dev' install, MO files will be installed in /misc/translator/po On 'standard' and 'single' installs, they will be installed in /../../misc/translator/po This patch makes Koha::I18N try to use the "dev" directory first, and fallback to the "standard" directory. If none of these directories exist, it dies. --- Koha/I18N.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Koha/I18N.pm b/Koha/I18N.pm index 72062239d8..ca0ceae0c9 100644 --- a/Koha/I18N.pm +++ b/Koha/I18N.pm @@ -24,6 +24,7 @@ use C4::Languages; use C4::Context; use Encode; +use List::Util qw( first ); use Locale::Messages qw(:locale_h LC_MESSAGES); use POSIX qw( setlocale ); use Koha::Cache::Memory::Lite; @@ -176,7 +177,20 @@ sub N__np { } sub _base_directory { - return C4::Context->config('intranetdir') . '/misc/translator/po'; + # Directory structure is not the same for dev and standard installs + # Here we test the existence of several directories and use the first that exist + # FIXME There has to be a better solution + my @dirs = ( + C4::Context->config('intranetdir') . '/misc/translator/po', + C4::Context->config('intranetdir') . '/../../misc/translator/po', + ); + my $dir = first { -d } @dirs; + + unless ($dir) { + die "The PO directory has not been found. There is a problem in your Koha installation."; + } + + return $dir; } sub _gettext { -- 2.20.1