diff --git a/inc/class-antivirus.php b/inc/class-antivirus.php index 2b293e9..d4f6227 100644 --- a/inc/class-antivirus.php +++ b/inc/class-antivirus.php @@ -352,24 +352,15 @@ public static function add_enqueue_script(): void { true ); + // Sets translated strings for the script. + wp_set_script_translations( 'av_script', 'antivirus' ); + // Localize script data. wp_localize_script( 'av_script', 'av_settings', array( 'nonce' => wp_create_nonce( 'av_ajax_nonce' ), - 'labels' => array( - 'dismiss' => esc_js( __( 'Dismiss', 'antivirus' ) ), - 'complete' => esc_js( __( 'Scan finished', 'antivirus' ) ), - 'file' => esc_js( __( 'Theme File', 'antivirus' ) ), - 'status' => esc_js( __( 'Check Status', 'antivirus' ) ), - ), - 'texts' => array( - 'dismiss' => esc_js( __( 'Dismiss false positive virus detection', 'antivirus' ) ), - 'ok' => esc_js( __( '✔ OK', 'antivirus' ) ), - 'pending' => esc_js( __( 'pending', 'antivirus' ) ), - 'warning' => esc_js( __( '! Warning', 'antivirus' ) ), - ), ) ); } diff --git a/js/script.js b/js/script.js index b474dea..4a8231a 100644 --- a/js/script.js +++ b/js/script.js @@ -39,7 +39,7 @@ jQuery(document).ready(($) => { 'av-status-pending' ); row.find('td.av-status-column').text( - av_settings.texts.warning + wp.i18n.__('! Warning', 'antivirus') ); // Initialize lines of current file. @@ -58,9 +58,12 @@ jQuery(document).ready(($) => { ' ' + - av_settings.labels.dismiss + + wp.i18n.__('Dismiss', 'antivirus') + '
' ); @@ -100,7 +103,9 @@ jQuery(document).ready(($) => { .removeClass('av-status-warning'); col.parent() .find('td.av-status-column') - .text(av_settings.texts.ok); + .text( + wp.i18n.__('✔ OK', 'antivirus') + ); } } ); @@ -113,7 +118,9 @@ jQuery(document).ready(($) => { row.addClass('av-status-ok').removeClass( 'av-status-pending' ); - row.find('td.av-status-column').text(av_settings.texts.ok); + row.find('td.av-status-column').text( + wp.i18n.__('✔ OK', 'antivirus') + ); } // Increment counter. @@ -124,7 +131,7 @@ jQuery(document).ready(($) => { $('#av-scan-process') .html( '' + - av_settings.labels.complete + + wp.i18n.__('Scan finished', 'antivirus') + '' ) .fadeOut() @@ -157,8 +164,12 @@ jQuery(document).ready(($) => { '| ' + - ' | Theme File | ' + - 'Check Status | ' + + '' + + wp.i18n.__('Theme File', 'antivirus') + + ' | ' + + '' + + wp.i18n.__('Check Status', 'antivirus') + + ' | ' + '' + - av_settings.texts.pending + + wp.i18n.__('pending', 'antivirus') + ' | ' + ''; }); @@ -196,9 +207,9 @@ jQuery(document).ready(($) => { '
|---|---|---|---|---|
| ' + ' | ' + - av_settings.labels.file + + wp.i18n.__('Theme File', 'antivirus') + ' | ' + - av_settings.labels.status + + wp.i18n.__('Check Status', 'antivirus') + ' |