Skip to content

Commit

Permalink
Upgrade to release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Nov 21, 2014
1 parent 4f1be6a commit 648a02e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions DateRangePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 += [
Expand All @@ -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
*
Expand Down Expand Up @@ -351,4 +359,4 @@ protected static function convertDateFormat($format)
'U' => 'X',
]);
}
}
}

0 comments on commit 648a02e

Please sign in to comment.