Skip to content

Commit

Permalink
Fix translations not loading for JavaScript files.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Feb 14, 2024
1 parent 36561c3 commit 260e423
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
34 changes: 16 additions & 18 deletions php/admin-menus/class-edit-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,37 +149,35 @@ public function enqueue_assets() {

enqueue_code_editor( $this->snippet->type );

$css_deps = [
'code-editor',
'wp-components',
];

$js_deps = [
'code-snippets-code-editor',
'react',
'react-dom',
'wp-url',
'wp-i18n',
'wp-api-fetch',
'wp-components',
'wp-block-editor',
];

wp_enqueue_style(
self::CSS_HANDLE,
plugins_url( "dist/edit$rtl.css", $plugin->file ),
$css_deps,
[
'code-editor',
'wp-components',
],
$plugin->version
);

wp_enqueue_script(
self::JS_HANDLE,
plugins_url( 'dist/edit.js', $plugin->file ),
$js_deps,
[
'code-snippets-code-editor',
'react',
'react-dom',
'wp-url',
'wp-i18n',
'wp-api-fetch',
'wp-components',
'wp-block-editor',
],
$plugin->version,
true
);

wp_set_script_translations( self::JS_HANDLE, 'code-snippets' );

if ( $desc_enabled ) {
remove_editor_styles();
wp_enqueue_editor();
Expand Down
2 changes: 2 additions & 0 deletions php/admin-menus/class-manage-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public function enqueue_assets() {
true
);

wp_set_script_translations( 'code-snippets-manage-js', 'code-snippets' );

if ( 'cloud_search' === $this->get_current_type() ) {
Frontend::enqueue_all_prism_themes();
}
Expand Down
2 changes: 2 additions & 0 deletions php/settings/editor-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ function enqueue_editor_preview_assets() {
true
);

wp_set_script_translations( 'code-snippets-settings-menu', 'code-snippets' );

// Extract the CodeMirror-specific editor settings.
$setting_fields = get_settings_fields();
$editor_fields = array();
Expand Down

0 comments on commit 260e423

Please sign in to comment.