/** * Set the current default locale and language. * * @param string $locale * * @throws \Punic\Exception\InvalidLocale Throws an exception if $locale is not a valid string */ public static function setDefaultLocale($locale) { if (is_null(static::explodeLocale($locale))) { throw new Exception\InvalidLocale($locale); } static::$defaultLocale = $locale; }
public function __construct($amount, $currency, $locale = null) { if (!empty($locale)) { static::$defaultLocale = $locale; } parent::__construct($amount, $currency); }
public static function addI18nCondition(ModelCriteria $query, $i18nTableName, $tableIdColumn, $i18nIdColumn, $localeColumn, $locale) { if (null === static::$defaultLocale) { static::$defaultLocale = Lang::getDefaultLanguage()->getLocale(); } $locale = static::realEscape($locale); $defaultLocale = static::realEscape(static::$defaultLocale); $query->_and()->where("CASE WHEN " . $tableIdColumn . " IN" . "(SELECT DISTINCT " . $i18nIdColumn . " " . "FROM `" . $i18nTableName . "` " . "WHERE locale={$locale}) " . "THEN " . $localeColumn . " = {$locale} " . "ELSE " . $localeColumn . " = {$defaultLocale} " . "END"); }
/** * Sets the default locale. * * @param string|null $locale The default locale string to be used or null. * @return void */ public static function setDefaultLocale($locale = null) { static::$defaultLocale = $locale; }
/** * @param string $locale */ public static function setDefaultLocale($locale = 'en_US') { static::$defaultLocale = $locale; }