Adding translation to ui datepicker
-
Like I explain in a previous thread, I build a little method to load the current jquery-ui-datepicker-i18n-%locale% where locale is the current local of the visitor.
cotrollers/shotcodes.php add this after line 77 :
$locale = self::getJqueryUII18nLocale(); wp_enqueue_script('jquery-ui-i18n-'.$locale, 'https://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/jquery.ui.datepicker-'.$locale.'.js', array('jquery-ui-datepicker'));
And add this method :
/** * Get the locale according to the format available in the jquery ui i18n file list * * @url https://github.com/jquery/jquery-ui/tree/master/ui/i18n * @return string ex: "fr" ou "en-GB" */ public static function getJqueryUII18nLocale() { //replace _ by - in "en_GB" for example $locale = str_replace( '_', '-', get_locale() ); switch ($locale) { case 'ar-DZ': case 'cy-GB': case 'en-AU': case 'en-GB': case 'en-NZ': case 'fr-CH': case 'nl-BE': case 'nl-BE': case 'pt-BR': case 'sr-SR': case 'zh-CN': case 'zh-HK': case 'zh-TW': //For all this locale do nothing the file already exist break; default: //for other locale keep the first part of the locale (ex: "fr-FR" -> "fr") $locale = substr($locale, 0, strpos($locale, '-')); break; } return $locale; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Adding translation to ui datepicker’ is closed to new replies.