Skip to content

Commit 1a52801

Browse files
committed
Localize editor and setting scripts separately.
1 parent 87cefac commit 1a52801

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

includes/class-block-visibility.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ private function __construct() {
7272
*/
7373
public function actions() {
7474
add_action( 'init', array( $this, 'load_textdomain' ) );
75-
add_action( 'admin_enqueue_scripts', array( $this, 'block_localization' ) );
75+
add_action( 'enqueue_block_editor_assets', array( $this, 'editor_scripts_localization' ) );
76+
77+
// Use admin_enqueue_scripts here, otherwise the settings page will not be translated.
78+
add_action( 'admin_enqueue_scripts', array( $this, 'setting_scripts_localization' ) );
7679

7780
// Specific fixes/work arounds for server-side blocks.
7881
add_action( 'wp_loaded', array( $this, 'add_attributes_to_registered_blocks' ), 999 );
@@ -205,18 +208,27 @@ public function load_textdomain() {
205208
}
206209

207210
/**
208-
* Enqueue localization data for our blocks.
211+
* Enqueue localization data for editor scripts.
209212
*
210213
* @since 1.0.0
211214
*/
212-
public function block_localization() {
215+
public function editor_scripts_localization() {
213216
if ( function_exists( 'wp_set_script_translations' ) ) {
214217
wp_set_script_translations(
215218
'block-visibility-editor-scripts',
216219
'block-visibility',
217220
BLOCK_VISIBILITY_ABSPATH . '/languages'
218221
);
222+
}
223+
}
219224

225+
/**
226+
* Enqueue localization data for setting page scripts.
227+
*
228+
* @since 2.6.0
229+
*/
230+
public function setting_scripts_localization() {
231+
if ( function_exists( 'wp_set_script_translations' ) ) {
220232
wp_set_script_translations(
221233
'block-visibility-setting-scripts',
222234
'block-visibility',

0 commit comments

Comments
 (0)