From 69c723af636e43334094082c22df3e7279260aca Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Mon, 9 Jan 2023 08:58:46 +0100 Subject: [PATCH] fix: quiqqer/shipping#45 --- src/QUI/ERP/Shipping/Types/Factory.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/QUI/ERP/Shipping/Types/Factory.php b/src/QUI/ERP/Shipping/Types/Factory.php index 4f61761..174b9fc 100644 --- a/src/QUI/ERP/Shipping/Types/Factory.php +++ b/src/QUI/ERP/Shipping/Types/Factory.php @@ -67,16 +67,17 @@ public function createChild($data = []) $NewChild = parent::createChild($data); $this->createShippingLocale( - 'shipping.'.$NewChild->getId().'.title', + 'shipping.' . $NewChild->getId() . '.title', $NewChild->getShippingType()->getTitle() ); $this->createShippingLocale( - 'shipping.'.$NewChild->getId().'.workingTitle', - $NewChild->getShippingType()->getTitle().' - '.$NewChild->getId() + 'shipping.' . $NewChild->getId() . '.workingTitle', + $NewChild->getShippingType()->getTitle() . ' - ' . $NewChild->getId() ); - $this->createShippingLocale('shipping.'.$NewChild->getId().'.decription', ''); + // description + $this->createShippingLocale('shipping.' . $NewChild->getId() . '.description', ' '); try { QUI\Translator::publish('quiqqer/shipping'); @@ -148,19 +149,22 @@ public function getChild($id) */ protected function createShippingLocale($var, $title) { - $current = QUI::getLocale()->getCurrent(); - if (QUI::getLocale()->isLocaleString($title)) { $parts = QUI::getLocale()->getPartsOfLocaleString($title); $title = QUI::getLocale()->get($parts[0], $parts[1]); } + $data = []; + + foreach (QUI::availableLanguages() as $language) { + $data[$language] = $title; + $data[$language . '_edit'] = $title; + } + + try { - QUI\Translator::addUserVar('quiqqer/shipping', $var, [ - $current => $title, - 'datatype' => 'php,js', - 'package' => 'quiqqer/shipping' - ]); + QUI\Translator::add('quiqqer/shipping', $var, 'quiqqer/shipping', 'php,js'); + QUI\Translator::update('quiqqer/shipping', $var, 'quiqqer/shipping', $data); } catch (QUI\Exception $Exception) { QUI\System\Log::addNotice($Exception->getMessage()); } -- GitLab