From cca32fe984a7065933f296995f5c43e785860a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnter?= Date: Tue, 16 Jun 2020 12:16:30 +0200 Subject: [PATCH] fix: correctly set the script translation text domain --- common/webpack.factory.ts | 1 + packages/utils/src/Assets.php | 2 +- packages/utils/src/PackageLocalization.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/webpack.factory.ts b/common/webpack.factory.ts index ed5f55c..a29998e 100755 --- a/common/webpack.factory.ts +++ b/common/webpack.factory.ts @@ -348,6 +348,7 @@ function createDefaultSettings( "process.env": definePlugin({ NODE_ENV: JSON.stringify(NODE_ENV), env: JSON.stringify(NODE_ENV), + rootSlug: JSON.stringify(rootPkg.name), slug: JSON.stringify(slug) }) }), diff --git a/packages/utils/src/Assets.php b/packages/utils/src/Assets.php index 1749d29..d1d2abd 100755 --- a/packages/utils/src/Assets.php +++ b/packages/utils/src/Assets.php @@ -381,7 +381,7 @@ protected function enqueueComposer( wp_enqueue_script($useHandle, $url, $deps, $cachebuster, $in_footer); $this->setLazyScriptTranslations( $useHandle, - $useHandle, + $rootSlug . '-' . $handle, path_join($pluginPath, $packageDir . 'languages/frontend/json') ); } else { diff --git a/packages/utils/src/PackageLocalization.php b/packages/utils/src/PackageLocalization.php index a3a1b85..b60172c 100755 --- a/packages/utils/src/PackageLocalization.php +++ b/packages/utils/src/PackageLocalization.php @@ -24,7 +24,7 @@ class PackageLocalization { * @param string $packageDir Absolute path to your package. * @codeCoverageIgnore */ - private function __construct($rootSlug, $packageDir) { + protected function __construct($rootSlug, $packageDir) { $this->rootSlug = $rootSlug; $this->packageDir = $packageDir; }