Tries to get the locale from Translatable, Fluent or the default i18n (depending on what is installed)
public static get_current_locale ( ) : string | ||
Результат | string | the locale in use |
/** * Force creating an order reference */ protected function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->getField("Reference") && in_array($this->Status, self::$placed_status)) { $this->generateReference(); } // perform status transition if ($this->isInDB() && $this->isChanged('Status')) { $this->statusTransition(empty($this->original['Status']) ? 'Cart' : $this->original['Status'], $this->Status); } // While the order is unfinished/cart, always store the current locale with the order. // We do this everytime an order is saved, because the user might change locale (language-switch). if ($this->Status == 'Cart') { $this->Locale = ShopTools::get_current_locale(); } }
/** * Force creating an order reference */ public function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->getField("Reference") && in_array($this->Status, self::$placed_status)) { $this->generateReference(); } // While the order is unfinished/cart, always store the current locale with the order. // We do this everytime an order is saved, because the user might change locale (language-switch). if ($this->Status == 'Cart') { $this->Locale = ShopTools::get_current_locale(); } }