Automattic\WooCommerce\Blocks\BlockTypes
AbstractBlock::register_chunk_translations()
Injects Chunk Translations into the page so translations work for lazy loaded components.
The chunk names are defined when creating lazy loaded components using webpackChunkName.
Method of the class: AbstractBlock{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->register_chunk_translations( $chunks );
- $chunks(string[]) (required)
- Array of chunk names.
AbstractBlock::register_chunk_translations() AbstractBlock::register chunk translations code WC 9.4.2
protected function register_chunk_translations( $chunks ) { foreach ( $chunks as $chunk ) { $handle = 'wc-blocks-' . $chunk . '-chunk'; $this->asset_api->register_script( $handle, $this->asset_api->get_block_asset_build_path( $chunk ), [], true ); wp_add_inline_script( $this->get_block_type_script( 'handle' ), wp_scripts()->print_translations( $handle, false ), 'before' ); wp_deregister_script( $handle ); } }