From 4072dfd26f2ea02cde6bec2d2e74e0cfa54d4bb0 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 5 Apr 2020 08:40:42 +0200 Subject: [PATCH] Use default strings if any of the minor translation files is not available --- services/LocalizationService.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/services/LocalizationService.php b/services/LocalizationService.php index e11c7f85..adc69846 100644 --- a/services/LocalizationService.php +++ b/services/LocalizationService.php @@ -66,13 +66,31 @@ class LocalizationService $this->PoUserStrings = new Translations(); $this->PoUserStrings->setDomain('grocy/userstrings'); - $this->Po = Translations::fromPoFile(__DIR__ . "/../localization/$culture/chore_period_types.po"); - $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/chore_assignment_types.po")); - $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/component_translations.po")); - $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/demo_data.po")); - $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/stock_transaction_types.po")); - $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/strings.po")); - $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/userfield_types.po")); + $this->Po = Translations::fromPoFile(__DIR__ . "/../localization/$culture/strings.po"); + if (file_exists("/../localization/$culture/chore_assignment_types.po")) + { + $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/chore_assignment_types.po")); + } + if (file_exists("/../localization/$culture/component_translations.po")) + { + $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/component_translations.po")); + } + if (file_exists("/../localization/$culture/demo_data.po")) + { + $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/demo_data.po")); + } + if (file_exists("/../localization/$culture/stock_transaction_types.po")) + { + $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/stock_transaction_types.po")); + } + if (file_exists("/../localization/$culture/chore_period_types.po")) + { + $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/chore_period_types.po")); + } + if (file_exists("/../localization/$culture/userfield_types.po")) + { + $this->Po = $this->Po->mergeWith(Translations::fromPoFile(__DIR__ . "/../localization/$culture/userfield_types.po")); + } $quantityUnits = null; try