Permalink
Browse files

Fix missing localized scripts for some languages #259

  • Loading branch information...
1 parent cdfc1cc commit a7e8416b1ea957c30e0f2728e9cc8925be127617 @rilwis committed Mar 27, 2013
Showing with 28 additions and 9 deletions.
  1. +11 −3 inc/fields/date.php
  2. +16 −5 inc/fields/datetime.php
  3. +1 −1 meta-box.php
View
@@ -2,7 +2,7 @@
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
-if ( ! class_exists( 'RWMB_Date_Field' ) )
+if ( !class_exists( 'RWMB_Date_Field' ) )
{
class RWMB_Date_Field
{
@@ -18,9 +18,17 @@ static function admin_enqueue_scripts()
wp_register_style( 'jquery-ui-theme', "{$url}/jquery.ui.theme.css", array(), '1.8.17' );
wp_enqueue_style( 'jquery-ui-datepicker', "{$url}/jquery.ui.datepicker.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
+ // Load localized scripts
$locale = str_replace( '_', '-', get_locale() );
- wp_register_script( 'jquery-ui-datepicker-i18n', RWMB_JS_URL . 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . $locale . '.js', array( 'jquery-ui-datepicker' ), '1.8.17', true );
- wp_enqueue_script( 'rwmb-date', RWMB_JS_URL . 'date.js', array( 'jquery-ui-datepicker-i18n' ), RWMB_VER, true );
+ $file_path = 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . $locale . '.js';
+ $deps = array( 'jquery-ui-datepicker' );
+ if ( file_exists( RWMB_DIR . 'js/' . $file_path ) )
+ {
+ wp_register_script( 'jquery-ui-datepicker-i18n', RWMB_JS_URL . $file_path, $deps, '1.8.17', true );
+ $deps[] = 'jquery-ui-datepicker-i18n';
+ }
+
+ wp_enqueue_script( 'rwmb-date', RWMB_JS_URL . 'date.js', $deps, RWMB_VER, true );
wp_localize_script( 'rwmb-date', 'RWMB_Datepicker', array( 'lang' => $locale ) );
}
View
@@ -20,14 +20,25 @@ static function admin_enqueue_scripts()
wp_register_style( 'jquery-ui-slider', "{$url}/jquery.ui.slider.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.css", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7' );
- $url = RWMB_JS_URL . 'jqueryui';
- wp_register_script( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
+ wp_register_script( 'jquery-ui-timepicker', RWMB_JS_URL . 'jqueryui/jquery-ui-timepicker-addon.js', array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '0.9.7', true );
+ // Load localized scripts
$locale = str_replace( '_', '-', get_locale() );
- wp_register_script( 'jquery-ui-datepicker-i18n', "{$url}/datepicker-i18n/jquery.ui.datepicker-{$locale}.js", array( 'jquery-ui-datepicker' ), '1.8.17', true );
- wp_register_script( 'jquery-ui-timepicker-i18n', "{$url}/timepicker-i18n/jquery-ui-timepicker-{$locale}.js", array( 'jquery-ui-timepicker' ), '0.9.7', true );
+ $date_path = 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . $locale . '.js';
+ $time_path = 'jqueryui/timepicker-i18n/jquery-ui-timepicker-' . $locale . '.js';
+ $deps = array( 'jquery-ui-datepicker', 'jquery-ui-timepicker' );
+ if ( file_exists( RWMB_DIR . 'js/' . $date_path ) )
+ {
+ wp_register_script( 'jquery-ui-datepicker-i18n', RWMB_JS_URL . $date_path, array( 'jquery-ui-datepicker' ), '1.8.17', true );
+ $deps[] = 'jquery-ui-datepicker-i18n';
+ }
+ if ( file_exists( RWMB_DIR . 'js/' . $time_path ) )
+ {
+ wp_register_script( 'jquery-ui-timepicker-i18n', RWMB_JS_URL . $time_path, array( 'jquery-ui-timepicker' ), '1.8.17', true );
+ $deps[] = 'jquery-ui-timepicker-i18n';
+ }
- wp_enqueue_script( 'rwmb-datetime', RWMB_JS_URL . 'datetime.js', array( 'jquery-ui-datepicker-i18n', 'jquery-ui-timepicker-i18n' ), RWMB_VER, true );
+ wp_enqueue_script( 'rwmb-datetime', RWMB_JS_URL . 'datetime.js', $deps, RWMB_VER, true );
wp_localize_script( 'rwmb-datetime', 'RWMB_Datetimepicker', array( 'lang' => $locale ) );
}
View
@@ -13,7 +13,7 @@
defined( 'ABSPATH' ) || exit;
// Script version, used to add version for scripts and styles
-define( 'RWMB_VER', '4.2.2' );
+define( 'RWMB_VER', '4.2.4' );
// Define plugin URLs, for fast enqueuing scripts and styles
if ( ! defined( 'RWMB_URL' ) )

0 comments on commit a7e8416

Please sign in to comment.