Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Translate JS error messages

Even though there's slight duplication of code, the
two pieces are independent and having one of them
depends on the other would result in more complexity
than it would be worth.

Also, there's no logic in the duplicated code, so
changing one without changing the other is fine.
  • Loading branch information...
commit f4e54ce6298d1773f571916b1dfbbf30760eb7d6 1 parent 7f724aa
Nikolay Bachiyski nb authored
Showing with 4 additions and 2 deletions.
  1. +1 −1  js/liveblog-admin.js
  2. +1 −1  js/liveblog.js
  3. +2 −0  liveblog.php
2  js/liveblog-admin.js
View
@@ -9,7 +9,7 @@ jQuery(function($) {
var url = ajaxurl + '?action=set_liveblog_state_for_post&post_id=' + encodeURIComponent(post_id) + '&state=' + encodeURIComponent($(this).val()) + '&' + liveblog_admin_settings.nonce_key + '=' + liveblog_admin_settings.nonce;
$('.inside', $meta_box).load(url, function(response, status, xhr) {
if ( status != 'error') return;
- show_error('Error: ' + xhr.status + ' ' + xhr.statusText);
+ show_error( liveblog_admin_settings.error_message_template.replace('{error-code}', xhr.status).replace('{error-message}', xhr.statusText));
});
});
});
2  js/liveblog.js
View
@@ -252,7 +252,7 @@ var liveblog = {};
liveblog.error_callback = function() {};
liveblog.add_error = function( response ) {
- alert( 'Error ' + response.status + ': ' + response.statusText );
+ alert( liveblog_settings.error_message_template.replace('{error-code}', response.status).replace('{error-message}', response.statusText));
};
liveblog.show_spinner = function() {
2  liveblog.php
View
@@ -421,6 +421,7 @@ public static function admin_enqueue_scripts() {
wp_localize_script( 'liveblog-admin', 'liveblog_admin_settings', array(
'nonce_key' => self::nonce_key,
'nonce' => wp_create_nonce( self::nonce_key ),
+ 'error_message_template' => __( 'Error {error-code}: {error-message}', 'liveblog' ),
) );
}
@@ -471,6 +472,7 @@ public static function enqueue_scripts() {
'update_nag_singular' => __( '%d new update', 'liveblog' ),
'update_nag_plural' => __( '%d new updates', 'liveblog' ),
'delete_confirmation' => __( 'Do you really want do delete this entry? There is no way back.', 'liveblog' ),
+ 'error_message_template' => __( 'Error {error-code}: {error-message}', 'liveblog' ),
) )
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.