From 9ab3521d5f186656b3d2fa85e79a62556de09758 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. Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize (cherry picked from commit 6028c92c7b299b85d871605cd46d5bb97b760f7b) (cherry picked from commit a43eb84800b8e744354b414e7a8220a55934ed68) Signed-off-by: Victor Grousset/tuxayo --- 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.39.5