Skip to content

Commit

Permalink
Finally got js translations working
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoensing committed Apr 25, 2020
1 parent 2582df2 commit f3fd57f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: SimpleTOC - Table of Contents Block
* Plugin URI: https://github.com/mtoensing/simpletoc
* Description: Adds a basic "Table of Contents" Gutenberg block.
* Version: 1.8
* Version: 1.9
* Author: MarcDK
* Author URI: marc.tv
* Text Domain: simpletoc
Expand All @@ -25,7 +25,7 @@
function init() {

wp_register_script(
'simpletoc',
'simpletoc-js',
plugins_url('build/index.js', __FILE__),
[ 'wp-i18n', 'wp-blocks', 'wp-editor', 'wp-element', 'wp-server-side-render'],
filemtime(plugin_dir_path(__FILE__) . 'build/index.js')
Expand All @@ -38,14 +38,7 @@ function init() {
filemtime(plugin_dir_path(__FILE__) . 'editor.css')
);

if (function_exists('wp_set_script_translations')) {
/**
* May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
* plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
* https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
*/
wp_set_script_translations('simpletoc-js', 'simpletoc');
}
wp_set_script_translations('simpletoc-js', 'simpletoc');

}

Expand All @@ -62,7 +55,7 @@ function register_block() {
}

register_block_type('simpletoc/toc', [
'editor_script' => 'simpletoc',
'editor_script' => 'simpletoc-js',
'editor_style' => 'simpletoc-editor',
'attributes' => array(
'plugin' => array(
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: MarcDK
Tags: Gutenberg, TOC, Table of Contents, Inhaltsverzeichnis, twenty-twenty
Requires at least: 5.0
Tested up to: 5.4
Stable tag: 1.8
Stable tag: 1.9
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down

0 comments on commit f3fd57f

Please sign in to comment.