From 648a02e478afa8684e3ddc96ad939367dbdb78ff Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Fri, 21 Nov 2014 20:07:59 +0530 Subject: [PATCH] Upgrade to release v1.3.0 --- DateRangePicker.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/DateRangePicker.php b/DateRangePicker.php index 5fa1bef..1d89a2e 100644 --- a/DateRangePicker.php +++ b/DateRangePicker.php @@ -180,17 +180,14 @@ protected function initRange() protected function initLocale() { $this->initLanguage(); $this->_localeLang = strtolower($this->language); - if (empty($this->_lang) || $this->_localelang === 'en') { + if (empty($this->_lang) || $this->_localeLang === 'en') { return; } - $s = DIRECTORY_SEPARATOR; - $file = __DIR__ . "{$s}assets{$s}js{$s}locale{$s}{$this->_localeLang}.js"; - if (!file_exists($file)) { + if (!static::isTranslatable($this->_localeLang)) { $this->_localeLang = $this->_lang; - } - $file = __DIR__ . "{$s}assets{$s}js{$s}locale{$s}{$this->_localeLang}.js"; - if (!file_exists($file)) { - return; + if (!static::isTranslatable($this->_localeLang)) { + return; + } } $localeSettings = ArrayHelper::getValue($this->pluginOptions, 'locale', []); $localeSettings += [ @@ -207,6 +204,17 @@ protected function initLocale() { $this->pluginOptions['locale'] = $localeSettings; } + /** + * Check if a translation is possible + * @param string $lang the language code + * @return bool + */ + protected static function isTranslatable($lang) { + $s = DIRECTORY_SEPARATOR; + $file = __DIR__ . "{$s}assets{$s}js{$s}locale{$s}{$lang}.js"; + return (!empty($lang) && $lang !== 'en' && file_exists($file)); + } + /** * Parses and returns a JsExpression * @@ -351,4 +359,4 @@ protected static function convertDateFormat($format) 'U' => 'X', ]); } -} \ No newline at end of file +}