Skip to content

Commit

Permalink
refactor: sub-plugins translation location
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Dec 16, 2024
1 parent 8c124da commit dc50a4d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
26 changes: 22 additions & 4 deletions inc/class-blocks-animation.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ public function enqueue_editor_assets() {
)
);

wp_set_script_translations( 'otter-animation', 'blocks-animation' );
if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) {
wp_set_script_translations( 'otter-animation', 'otter-blocks' );
} else {
wp_set_script_translations( 'otter-animation', 'blocks-animation' );
}

$asset_file = include BLOCKS_ANIMATION_PATH . '/build/animation/anim-count.asset.php';
wp_enqueue_script(
Expand All @@ -104,7 +108,12 @@ public function enqueue_editor_assets() {
);

wp_script_add_data( 'otter-count', 'defer', true );
wp_set_script_translations( 'otter-count', 'blocks-animation' );

if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) {
wp_set_script_translations( 'otter-count', 'otter-blocks' );
} else {
wp_set_script_translations( 'otter-count', 'blocks-animation' );
}

wp_enqueue_script(
'otter-typing',
Expand All @@ -115,7 +124,12 @@ public function enqueue_editor_assets() {
);

wp_script_add_data( 'otter-typing', 'defer', true );
wp_set_script_translations( 'otter-typing', 'blocks-animation' );

if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) {
wp_set_script_translations( 'otter-typing', 'otter-blocks' );
} else {
wp_set_script_translations( 'otter-typing', 'blocks-animation' );
}
}

/**
Expand Down Expand Up @@ -253,7 +267,11 @@ public function render_welcome_notice() {
true
);

wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'blocks-animation' );
if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) {
wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'otter-blocks' );
} else {
wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'blocks-animation' );
}

wp_localize_script(
'otter-animation-welcome-notice-scripts',
Expand Down
7 changes: 5 additions & 2 deletions inc/class-blocks-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function enqueue_editor_assets() {
$asset_file['version'],
true
);
wp_set_script_translations( 'otter-css', 'blocks-css' );

wp_localize_script(
'otter-css',
Expand All @@ -87,7 +86,11 @@ public function enqueue_editor_assets() {
)
);

wp_set_script_translations( 'otter-css', 'blocks-css' );
if ( ! defined( 'BLOCKS_CSS_URL' ) ) {
wp_set_script_translations( 'otter-css', 'otter-blocks' );
} else {
wp_set_script_translations( 'otter-css', 'blocks-css' );
}

wp_enqueue_style(
'otter-css',
Expand Down
8 changes: 6 additions & 2 deletions inc/class-blocks-export-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ public function enqueue_editor_assets() {
$asset_file['version'],
true
);

wp_set_script_translations( 'blocks-export-import', 'blocks-export-import' );

if ( ! defined( 'BLOCKS_EXPORT_IMPORT_URL' ) ) {
wp_set_script_translations( 'blocks-export-import', 'otter-blocks' );
} else {
wp_set_script_translations( 'blocks-export-import', 'blocks-export-import' );
}
}

/**
Expand Down

0 comments on commit dc50a4d

Please sign in to comment.