From 389d095b965011d24c1a2e9d887ccf527b18991f Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Wed, 30 Jul 2025 07:31:08 +0200 Subject: [PATCH 1/8] Contact requests should not go through info@acato.nl. A better option should be created, but for now, use service with a tag. --- includes/admin/class-admin.php | 2 +- includes/class-autoloader.php | 2 +- includes/class-base-block.php | 2 +- includes/class-i18n.php | 2 +- includes/class-plugin.php | 2 +- includes/frontend/class-frontend.php | 2 +- src/blocks/block-list.php | 2 +- src/blocks/owc-openkaarten/streetmap/class-streetmap.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index a459a2d..88e28ef 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -18,7 +18,7 @@ * * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Includes/Admin - * @author Acato + * @author Acato */ class Admin { /** diff --git a/includes/class-autoloader.php b/includes/class-autoloader.php index 1326225..0abcdc9 100644 --- a/includes/class-autoloader.php +++ b/includes/class-autoloader.php @@ -18,7 +18,7 @@ * @since 0.1.0 * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Includes - * @author Acato + * @author Acato */ class Autoloader { diff --git a/includes/class-base-block.php b/includes/class-base-block.php index db333e0..d0c67d9 100644 --- a/includes/class-base-block.php +++ b/includes/class-base-block.php @@ -20,7 +20,7 @@ * @since 0.1.0 * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Includes - * @author Acato + * @author Acato */ abstract class Base_Block { /** diff --git a/includes/class-i18n.php b/includes/class-i18n.php index d17a8b3..900f888 100644 --- a/includes/class-i18n.php +++ b/includes/class-i18n.php @@ -22,7 +22,7 @@ * @since 0.1.0 * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Includes - * @author Acato + * @author Acato */ class I18n { diff --git a/includes/class-plugin.php b/includes/class-plugin.php index 8d8464f..e56e956 100644 --- a/includes/class-plugin.php +++ b/includes/class-plugin.php @@ -28,7 +28,7 @@ * @since 0.1.0 * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Includes - * @author Acato + * @author Acato */ class Plugin { diff --git a/includes/frontend/class-frontend.php b/includes/frontend/class-frontend.php index 7ecc698..cac5157 100644 --- a/includes/frontend/class-frontend.php +++ b/includes/frontend/class-frontend.php @@ -18,7 +18,7 @@ * * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Includes/Frontend - * @author Acato + * @author Acato */ class Frontend { diff --git a/src/blocks/block-list.php b/src/blocks/block-list.php index 17111f9..c9253ce 100644 --- a/src/blocks/block-list.php +++ b/src/blocks/block-list.php @@ -8,7 +8,7 @@ * * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Src/Blocks - * @author Acato info@acato.nl> + * @author Acato */ return [ diff --git a/src/blocks/owc-openkaarten/streetmap/class-streetmap.php b/src/blocks/owc-openkaarten/streetmap/class-streetmap.php index 8c8b71e..8af5f5a 100644 --- a/src/blocks/owc-openkaarten/streetmap/class-streetmap.php +++ b/src/blocks/owc-openkaarten/streetmap/class-streetmap.php @@ -22,7 +22,7 @@ * @since 0.1.0 * @package Openkaarten_Frontend_Plugin * @subpackage Openkaarten_Frontend_Plugin/Src/Blocks/OWC_Openkaarten/Streetmap - * @author Acato + * @author Acato */ class Streetmap extends Base_Block { /** From c7ce9c373c4503857d48a12debec6b7567872f09 Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Wed, 30 Jul 2025 07:52:05 +0200 Subject: [PATCH 2/8] Add NPM commands for i18n management. --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f5d6dea..258a17c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,13 @@ "lint:js": "wp-scripts lint-js", "start": "wp-scripts start src/blocks/index.js", "start-assets": "npx mix watch", - "packages-update": "wp-scripts packages-update" + "packages-update": "wp-scripts packages-update", + "i18n": "npm run make-pot ; npm run update-po ; npm run make-mo ; npm run make-json ; npm run make-php", + "make-pot": "wp i18n make-pot . languages/openkaarten-frontend-plugin.pot --exclude=node_modules,build,languages", + "update-po": "wp i18n update-po languages/openkaarten-frontend-plugin.pot languages/", + "make-mo": "wp i18n make-mo languages/", + "make-json": "wp i18n make-json languages/", + "make-php": "wp i18n make-php languages/" }, "devDependencies": { "@vue/compiler-sfc": "^3.3.2", From 291a9e064cdfa3221fb3522b64a3c8caa6135630 Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Wed, 30 Jul 2025 07:52:35 +0200 Subject: [PATCH 3/8] Update POT, add translations and update the compiled files. --- ...l_NL-a6d89d02facc49d2994e1a4275125118.json | 2 +- ...openkaarten-frontend-plugin-nl_NL.l10n.php | 2 + .../openkaarten-frontend-plugin-nl_NL.mo | Bin 1205 -> 973 bytes .../openkaarten-frontend-plugin-nl_NL.po | 21 ++----- languages/openkaarten-frontend-plugin.pot | 55 +++++++++++++----- 5 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 languages/openkaarten-frontend-plugin-nl_NL.l10n.php diff --git a/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json b/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json index 21604b1..54286e6 100644 --- a/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json +++ b/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json @@ -1 +1 @@ -{"translation-revision-date":"2024-08-13 16:54+0200","generator":"WP-CLI\/2.8.1","source":"src\/blocks\/owc-openkaarten\/streetmap\/assets\/scripts\/edit.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"nl_NL","plural-forms":"nplurals=2; plural=(n != 1);"},"Select the datalayers you want to display on the map":["Selecteer de datalayers die getoond dienen te worden op de kaart"],"No datalayers selected":["Geen datalayers geselecteerd"],"Select datalayers:":["Selecteer datalayers"],"Selected datalayers":["Geselecteerde datalayers"]}}} \ No newline at end of file +{"translation-revision-date":"2024-08-13 16:54+0200","generator":"WP-CLI\/2.12.0","source":"src\/blocks\/owc-openkaarten\/streetmap\/assets\/scripts\/edit.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"nl_NL","plural-forms":"nplurals=2; plural=(n != 1);"},"Invalid URL":[""],"Error parsing nested JSON":[""],"Unexpected response format or 'datasets' is not an array.":[""],"Fetching datasets failed":[""],"Select the datalayers you want to display on the map":[""],"No datalayers found":[""],"No datalayers selected":[""],"URL to rest-endpoint or Domain URL":[""],"Select datalayers:":[""],"Selected datalayers":[""],"URL template for tile layer":[""]}}} \ No newline at end of file diff --git a/languages/openkaarten-frontend-plugin-nl_NL.l10n.php b/languages/openkaarten-frontend-plugin-nl_NL.l10n.php new file mode 100644 index 0000000..a62eb0c --- /dev/null +++ b/languages/openkaarten-frontend-plugin-nl_NL.l10n.php @@ -0,0 +1,2 @@ +'openkaarten-frontend-plugin','plural-forms'=>NULL,'language'=>'nl_NL','project-id-version'=>'OpenKaarten Frontend Plugin 0.1.0','pot-creation-date'=>'2024-06-13T09:17:05+00:00','po-revision-date'=>'2024-08-13 16:54+0200','x-generator'=>'Poedit 3.4.1','messages'=>['Adds OpenKaarten Blocks to the Gutenberg editor.'=>'Voegt OpenKaarten blokken toe aan de Gutenberg editor.','OpenKaarten Blocks'=>'OpenKaarten blokken','block titleOWC Openmaps Openstreet Map'=>'OpenKaarten Openstreetmap Kaart','block descriptionOWC Openmaps Openstreet Map'=>'OpenKaarten Openstreetmap Kaart','block keywordopenmaps'=>'openkaarten','block keywordmap'=>'kaart','block keywordlocations'=>'locaties']]; \ No newline at end of file diff --git a/languages/openkaarten-frontend-plugin-nl_NL.mo b/languages/openkaarten-frontend-plugin-nl_NL.mo index 75fa092dd8670b636ac556ad14ee1accc4519d30..fd2c5f0cbc7c955585f6977edb0a90d035ef1ede 100644 GIT binary patch delta 172 zcmdnWd6vEYo)F7a1|Z-7Vi_Qg0das}4uk^J20->)AQl4Rb3m*M#1Da39EkZD85jhC zv^tO$1Jag2S{+CS0O@r=Tmi&pAbDm624Nr_2c+eJbP+AQl4RcR;KI#Egs#42D2j4@m0* z=>#Ax4y5~lv>=dP2BgJ+^bR1c4y4Zm>2*N-9f-|9^2`hj!VC=740nMHbD+RSAPure zlZAmn9!N(4X$~M=1*BPlbTg3V2GX5S`Kc@uXSv7u7o_H8Cngq^q~<9&B^IYDWELyr z<(DXA<`tJD=H#TNDC8F@Bqo<+mZd5(gk%6^3vx=+GxHRRQVUBni&BdfN-|OvFie3c z(%bl88dC~}@tLV53hAkb*F&vHEdpAS1{8r<1LP_)xTIF4!fZ-P&C5^8Oixir!D3MW L*fn~S3z=g8;>TeT diff --git a/languages/openkaarten-frontend-plugin-nl_NL.po b/languages/openkaarten-frontend-plugin-nl_NL.po index 72aa7ef..5ebca66 100644 --- a/languages/openkaarten-frontend-plugin-nl_NL.po +++ b/languages/openkaarten-frontend-plugin-nl_NL.po @@ -14,27 +14,27 @@ msgstr "" "X-Domain: openkaarten-frontend-plugin\n" #. Plugin Name of the plugin -#: openkaarten-plugin.php +#: openkaarten-frontend-plugin.php msgid "OpenKaarten Frontend Plugin" msgstr "" #. Plugin URI of the plugin -#: openkaarten-plugin.php +#: openkaarten-frontend-plugin.php msgid "https://openwebconcept.nl/" msgstr "" #. Description of the plugin -#: openkaarten-plugin.php +#: openkaarten-frontend-plugin.php msgid "Adds OpenKaarten Blocks to the Gutenberg editor." msgstr "Voegt OpenKaarten blokken toe aan de Gutenberg editor." #. Author of the plugin -#: openkaarten-plugin.php +#: openkaarten-frontend-plugin.php msgid "Acato" msgstr "" #. Author URI of the plugin -#: openkaarten-plugin.php +#: openkaarten-frontend-plugin.php msgid "https://www.acato.nl" msgstr "" @@ -42,14 +42,6 @@ msgstr "" msgid "OpenKaarten Blocks" msgstr "OpenKaarten blokken" -#: openkaarten-plugin.php:64 -msgid "This plugin requires the Openkaarten Base plugin." -msgstr "Deze plugin benodigd de Openkaarten Base Plugin." - -#: openkaarten-plugin.php:64 -msgid "Openkaarten Base is not installed or active!" -msgstr "Openkaarten Base is niet geïnstalleerd of geactiveerd!" - #: src/blocks/owc-openkaarten/streetmap/block.json msgctxt "block title" msgid "OWC Openmaps Openstreet Map" @@ -84,6 +76,3 @@ msgstr "kaart" msgctxt "block keyword" msgid "locations" msgstr "locaties" - -#~ msgid "Select datalayers to display:" -#~ msgstr "Selecteer datalayers om te tonen" diff --git a/languages/openkaarten-frontend-plugin.pot b/languages/openkaarten-frontend-plugin.pot index 679ece4..2742136 100644 --- a/languages/openkaarten-frontend-plugin.pot +++ b/languages/openkaarten-frontend-plugin.pot @@ -1,36 +1,41 @@ -# Copyright (C) 2024 Acato +# Copyright (C) 2025 Acato # This file is distributed under the same license as the OpenKaarten Frontend Plugin plugin. msgid "" msgstr "" -"Project-Id-Version: OpenKaarten Frontend Plugin 0.1.0\n" +"Project-Id-Version: OpenKaarten Frontend Plugin 0.2.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/openkaarten-frontend-plugin\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-08-13T14:51:28+00:00\n" +"POT-Creation-Date: 2025-07-30T05:47:46+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.8.1\n" +"X-Generator: WP-CLI 2.12.0\n" "X-Domain: openkaarten-frontend-plugin\n" #. Plugin Name of the plugin +#: openkaarten-frontend-plugin.php msgid "OpenKaarten Frontend Plugin" msgstr "" #. Plugin URI of the plugin +#: openkaarten-frontend-plugin.php msgid "https://openwebconcept.nl/" msgstr "" #. Description of the plugin +#: openkaarten-frontend-plugin.php msgid "Adds OpenKaarten Blocks to the Gutenberg editor." msgstr "" #. Author of the plugin +#: openkaarten-frontend-plugin.php msgid "Acato" msgstr "" #. Author URI of the plugin +#: openkaarten-frontend-plugin.php msgid "https://www.acato.nl" msgstr "" @@ -38,35 +43,53 @@ msgstr "" msgid "OpenKaarten Blocks" msgstr "" -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:45 -msgid "Select the datalayers you want to display on the map" +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:14 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:16 +msgid "Invalid URL" msgstr "" -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:61 -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:112 -msgid "No datalayers selected" +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:59 +msgid "Error parsing nested JSON" msgstr "" -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:81 -msgid "URL to rest-endpoint or Domain URL" +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:70 +msgid "Unexpected response format or 'datasets' is not an array." msgstr "" -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:94 -msgid "Invalid URL" +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:76 +msgid "Fetching datasets failed" msgstr "" -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:101 -msgid "Select datalayers:" +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:95 +msgid "Select the datalayers you want to display on the map" msgstr "" -#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:106 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:95 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:156 msgid "No datalayers found" msgstr "" #: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:111 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:162 +msgid "No datalayers selected" +msgstr "" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:131 +msgid "URL to rest-endpoint or Domain URL" +msgstr "" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:151 +msgid "Select datalayers:" +msgstr "" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:161 msgid "Selected datalayers" msgstr "" +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:166 +msgid "URL template for tile layer" +msgstr "" + #: src/blocks/owc-openkaarten/streetmap/block.json msgctxt "block title" msgid "OWC Openmaps Openstreet Map" From 10f797b90bc4d7949206fce121e3b90b4ff6ad54 Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Wed, 30 Jul 2025 07:53:37 +0200 Subject: [PATCH 4/8] The fix that started this entire PR - Early Output breaking the website and more issues, see code comments --- includes/class-i18n.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/includes/class-i18n.php b/includes/class-i18n.php index 900f888..4394373 100644 --- a/includes/class-i18n.php +++ b/includes/class-i18n.php @@ -35,15 +35,36 @@ public function __construct() { /** * Load the plugin text domain for translation. + * + * @return bool */ public function load_plugin_textdomain() { $path = dirname( plugin_basename( __FILE__ ), 2 ) . '/languages/'; $result = load_plugin_textdomain( 'openkaarten-frontend-plugin', false, $path ); if ( $result ) { - return; + return true; } + return false; + /** + * To be discussed; Why did I remove this? (RP 2025-07-30) + * 1. $locale using get_locale() is the site locale, not the user locale. - The user locale could be different, so this is not correct. + * I noticed this during debugging, load_plugin_textdomain uses determine_locale(), not get_locale(). + * 2. The path displayed here is not correct; the correct path is $path/$textdomain-$locale.mo. + * So in my case, the error was + * Could not find openkaarten-frontend-plugin/languages//nl_NL.mo + * while it should have been + * Could not find openkaarten-frontend-plugin/languages/openkaarten-frontend-plugin-en_US.mo + * 3. We'll ignore the double slash for now + * 4. This error message is printed before any legitimate output, breaking every POST, potentially breaking every AJAX/REST call and at the + * minimum showing the error in raw HTML. At least this should be an error_log, but preferably a wrapper into Admin Notices. + * In my case it only broke wp-admin as I have set Admin to English whereas the site is in Dutch, but in case of a non-NL site, + * this would break the site. + * 5. Since all source texts are in English; at least, the error should not show on `en_*` locales. + * 6. Finally, the filter construction here is interesting; It is only used here, so it doesn't do anything, also, the expected intention is + * to allow the user to change the locale using a filter, but that is not how WordPress works (unfortunately). + */ $locale = apply_filters( 'openkaarten_frontend_plugin_locale', get_locale(), 'openkaarten-frontend-plugin' ); echo wp_kses_post( "Could not find $path/$locale.mo" ); } From b95ac62761505cd0ee9e6a34c1f1386ca1ee429b Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Wed, 30 Jul 2025 07:58:15 +0200 Subject: [PATCH 5/8] Reformat comments to shopw better in Github. --- includes/class-i18n.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/class-i18n.php b/includes/class-i18n.php index 4394373..58d2b5d 100644 --- a/includes/class-i18n.php +++ b/includes/class-i18n.php @@ -49,21 +49,23 @@ public function load_plugin_textdomain() { return false; /** * To be discussed; Why did I remove this? (RP 2025-07-30) - * 1. $locale using get_locale() is the site locale, not the user locale. - The user locale could be different, so this is not correct. - * I noticed this during debugging, load_plugin_textdomain uses determine_locale(), not get_locale(). + * 1. $locale using get_locale() is the site locale, not the user locale. - The user locale could be different, so this + * is not correct. I noticed this during debugging, load_plugin_textdomain uses determine_locale(), not get_locale(). * 2. The path displayed here is not correct; the correct path is $path/$textdomain-$locale.mo. * So in my case, the error was * Could not find openkaarten-frontend-plugin/languages//nl_NL.mo * while it should have been * Could not find openkaarten-frontend-plugin/languages/openkaarten-frontend-plugin-en_US.mo * 3. We'll ignore the double slash for now - * 4. This error message is printed before any legitimate output, breaking every POST, potentially breaking every AJAX/REST call and at the - * minimum showing the error in raw HTML. At least this should be an error_log, but preferably a wrapper into Admin Notices. - * In my case it only broke wp-admin as I have set Admin to English whereas the site is in Dutch, but in case of a non-NL site, - * this would break the site. + * 4. This error message is printed before any legitimate output, breaking every POST, potentially breaking every AJAX/ + * REST call and at the minimum showing the error in raw HTML. At least this should be an error_log, but preferably a + * wrapper into Admin Notices. + * In my case it only broke wp-admin as I have set Admin to English whereas the site is in Dutch, but in case of a + * non-NL site, this would break the site. * 5. Since all source texts are in English; at least, the error should not show on `en_*` locales. - * 6. Finally, the filter construction here is interesting; It is only used here, so it doesn't do anything, also, the expected intention is - * to allow the user to change the locale using a filter, but that is not how WordPress works (unfortunately). + * 6. Finally, the filter construction here is interesting; It is only used here, so it doesn't do anything, also, the + * expected intention is to allow the user to change the locale using a filter, but that is not how WordPress works + * (unfortunately). */ $locale = apply_filters( 'openkaarten_frontend_plugin_locale', get_locale(), 'openkaarten-frontend-plugin' ); echo wp_kses_post( "Could not find $path/$locale.mo" ); From 65f02a6176e5a9c997a20a060247a8fb3a986fb8 Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Wed, 30 Jul 2025 08:02:37 +0200 Subject: [PATCH 6/8] Rebalance whitespace in package.json --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 258a17c..f9fc452 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,12 @@ "start": "wp-scripts start src/blocks/index.js", "start-assets": "npx mix watch", "packages-update": "wp-scripts packages-update", - "i18n": "npm run make-pot ; npm run update-po ; npm run make-mo ; npm run make-json ; npm run make-php", - "make-pot": "wp i18n make-pot . languages/openkaarten-frontend-plugin.pot --exclude=node_modules,build,languages", - "update-po": "wp i18n update-po languages/openkaarten-frontend-plugin.pot languages/", - "make-mo": "wp i18n make-mo languages/", - "make-json": "wp i18n make-json languages/", - "make-php": "wp i18n make-php languages/" + "i18n": "npm run make-pot ; npm run update-po ; npm run make-mo ; npm run make-json ; npm run make-php", + "make-pot": "wp i18n make-pot . languages/openkaarten-frontend-plugin.pot --exclude=node_modules,build,languages", + "update-po": "wp i18n update-po languages/openkaarten-frontend-plugin.pot languages/", + "make-mo": "wp i18n make-mo languages/", + "make-json": "wp i18n make-json languages/", + "make-php": "wp i18n make-php languages/" }, "devDependencies": { "@vue/compiler-sfc": "^3.3.2", From 4f42695b226145a6b7e049156cf6765aee2699ff Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Mon, 18 Aug 2025 11:26:09 +0200 Subject: [PATCH 7/8] Removing error message when MO file is not found To be discussed; Why did I remove this? (RP 2025-07-30) 1. $locale using get_locale() is the site locale, not the user locale. - The user locale could be different, so this is not correct. I noticed this during debugging, load_plugin_textdomain uses determine_locale(), not get_locale(). 2. The path displayed here is not correct; the correct path is $path/$textdomain-$locale.mo. So in my case, the error was `Could not find openkaarten-frontend-plugin/languages//nl_NL.mo` while it should have been `Could not find openkaarten-frontend-plugin/languages/openkaarten-frontend-plugin-en_US.mo` 3. We'll ignore the double slash for now 4. This error message is printed before any legitimate output, breaking every POST, potentially breaking every AJAX/REST call and at the minimum showing the error in raw HTML. At least this should be an error_log, but preferably a wrapper into Admin Notices. In my case it only broke wp-admin as I have set Admin to English whereas the site is in Dutch, but in case of a non-NL site, this would break the site. 5. Since all source texts are in English; at least, the error should not show on `en_*` locales. 6. Finally, the filter construction here is interesting; It is only used here, so it doesn't do anything, also, the expected intention is to allow the user to change the locale using a filter, but that is not how WordPress works (unfortunately). --- includes/class-i18n.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/includes/class-i18n.php b/includes/class-i18n.php index 58d2b5d..6aabc7a 100644 --- a/includes/class-i18n.php +++ b/includes/class-i18n.php @@ -47,27 +47,5 @@ public function load_plugin_textdomain() { } return false; - /** - * To be discussed; Why did I remove this? (RP 2025-07-30) - * 1. $locale using get_locale() is the site locale, not the user locale. - The user locale could be different, so this - * is not correct. I noticed this during debugging, load_plugin_textdomain uses determine_locale(), not get_locale(). - * 2. The path displayed here is not correct; the correct path is $path/$textdomain-$locale.mo. - * So in my case, the error was - * Could not find openkaarten-frontend-plugin/languages//nl_NL.mo - * while it should have been - * Could not find openkaarten-frontend-plugin/languages/openkaarten-frontend-plugin-en_US.mo - * 3. We'll ignore the double slash for now - * 4. This error message is printed before any legitimate output, breaking every POST, potentially breaking every AJAX/ - * REST call and at the minimum showing the error in raw HTML. At least this should be an error_log, but preferably a - * wrapper into Admin Notices. - * In my case it only broke wp-admin as I have set Admin to English whereas the site is in Dutch, but in case of a - * non-NL site, this would break the site. - * 5. Since all source texts are in English; at least, the error should not show on `en_*` locales. - * 6. Finally, the filter construction here is interesting; It is only used here, so it doesn't do anything, also, the - * expected intention is to allow the user to change the locale using a filter, but that is not how WordPress works - * (unfortunately). - */ - $locale = apply_filters( 'openkaarten_frontend_plugin_locale', get_locale(), 'openkaarten-frontend-plugin' ); - echo wp_kses_post( "Could not find $path/$locale.mo" ); } } From 84ede2643b072d9af9e6b0c0a45a11ade2810782 Mon Sep 17 00:00:00 2001 From: Remon Pel Date: Mon, 18 Aug 2025 11:52:37 +0200 Subject: [PATCH 8/8] Add --no-purge to make-json because for some stupid reason, WordPress decided to remove the items from PO and MO. MO I can understand, because JS strings are not needed in PHP, but removing them from PO means removing them from JSON as well, next run. https://github.com/wp-cli/i18n-command/issues/453 --- ...l_NL-a6d89d02facc49d2994e1a4275125118.json | 2 +- .../openkaarten-frontend-plugin-nl_NL.mo | Bin 973 -> 1836 bytes .../openkaarten-frontend-plugin-nl_NL.po | 47 ++++++++++++++++++ languages/openkaarten-frontend-plugin.pot | 2 +- package.json | 2 +- 5 files changed, 50 insertions(+), 3 deletions(-) diff --git a/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json b/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json index 54286e6..0e4b088 100644 --- a/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json +++ b/languages/openkaarten-frontend-plugin-nl_NL-a6d89d02facc49d2994e1a4275125118.json @@ -1 +1 @@ -{"translation-revision-date":"2024-08-13 16:54+0200","generator":"WP-CLI\/2.12.0","source":"src\/blocks\/owc-openkaarten\/streetmap\/assets\/scripts\/edit.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"nl_NL","plural-forms":"nplurals=2; plural=(n != 1);"},"Invalid URL":[""],"Error parsing nested JSON":[""],"Unexpected response format or 'datasets' is not an array.":[""],"Fetching datasets failed":[""],"Select the datalayers you want to display on the map":[""],"No datalayers found":[""],"No datalayers selected":[""],"URL to rest-endpoint or Domain URL":[""],"Select datalayers:":[""],"Selected datalayers":[""],"URL template for tile layer":[""]}}} \ No newline at end of file +{"translation-revision-date":"2024-08-13 16:54+0200","generator":"WP-CLI\/2.12.0","source":"src\/blocks\/owc-openkaarten\/streetmap\/assets\/scripts\/edit.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"nl_NL","plural-forms":"nplurals=2; plural=(n != 1);"},"Invalid URL":["Ongeldige URL"],"Error parsing nested JSON":["Fout bij het parsen van geneste JSON"],"Unexpected response format or 'datasets' is not an array.":["Onverwachte opbouw van antwoord, of 'datasets' is geen array."],"Fetching datasets failed":["Het ophalen van datasets is mislukt"],"Select the datalayers you want to display on the map":["Selecteer de datalagen die u op de kaart wilt weergeven"],"No datalayers found":["Geen datalagen gevonden"],"No datalayers selected":["Geen datalagen geselecteerd"],"URL to rest-endpoint or Domain URL":["URL naar rest-eindpunt of domein-URL"],"Select datalayers:":["Selecteer datalagen:"],"Selected datalayers":["Geselecteerde datalagen"],"URL template for tile layer":["URL-sjabloon voor tegel-laag"]}}} \ No newline at end of file diff --git a/languages/openkaarten-frontend-plugin-nl_NL.mo b/languages/openkaarten-frontend-plugin-nl_NL.mo index fd2c5f0cbc7c955585f6977edb0a90d035ef1ede..ec0cdb7e81460ffd3577f4bee66d6f5c522fa920 100644 GIT binary patch literal 1836 zcmaKs&u<(x6vw9!eklBqD5!uy;t7z7RJ@s_X_^eG5KWU1$Y#@Y({e-3`eoMHS$kxA zcAE?T1ft>(;EaUC5&j2y7zMk3DX4|SOtv=)D=jZ3=_w^qa7rsmIdmaCG z@&7pv@Y}mEV~Wo<#&3h)fNz1{gD-(UfpP7x;3e=OcoF<_!hgY4j9-1G@!JI7!T28d zKIp*>@Bt{m-@rG)|G?M4OV2iOKLRgf{3-Y&V&>ploPRD!J_Os~2cQFA0Uv-d&JSSR z?-wxU`8)Uq_!oE`yzqSEw*kiU-v(nm1Kt3?1>XZ7f-i!9gIJpU1IF_wFEsNngUM$~ zdFqsGzLe4hHgvPFy@97-DfF3kD%g(M<-|${>srZ{bJkHQo!2HO!#=R0FYa{qlWh*Y zel#i>r03x2MCyW7vTH`N(29-@_mX{EPZ#ox9UN?B)FU>}1@{m%c|5D+PCa)nLN+zU zWaGY*z-P9iu{0r`Lup^aOxDy#8p?9A2#L>@B*=~e58)aZi8%^Lp6YnboF#|T3O1^= z8lmBG%MPVB^}&t|-!JRLqg!c>ucHiQ?Ra@wlgp$%85>9%lFrGqR&pFGPKtfc=`v_* z7CQGf>pMZJ&E@#um;<$udgDFdv$1t*0ZV0E;vcccL(Y3z+;NOIF$WzAe(FXC&Yt2t zVpoZ~xGQXu%{9ulvj)wf=%A=_6d`Rbx6;K!F0Biq?Q^Zf%_{ezYcuMHQ2K0XDdt?F zJicXJzT~SiIxm%VfTft>py@(!G6^o4xy3z+%6FYK9@k@CMzEN?k~xbm%OS??-S*Zj z(U{6+ogbE+m7L*f@5h~RU7t{|kM`wopF{D=#Gq5(v?+_u8HNV-E<>czMiGmuB2&}rf?RAJkqgTbH3~FrRBBk+Uk{b1%A`? zGcv{3`+JLDi5)iVn!_E~s5ZLVT5T<3rs=Ybo>rjbuH`(;T@dbnFo2?iWs+z&^&~lO z+bYnpKBYeTE2gn za|@%og+Gf`7>{{-Z*K$8dH{6iPN8?{5MR6oi|BXagheX8VK8_d0tPg?pv$dW6h delta 212 zcmZ3(cb2{Wo)F7a1|Z-7Vi_Qg0das}4uk^J20->)AQl4Rb3m*M#1Da39EkZD85jhC zv^tO$1Jag2S{+CS0O@r=Tmi&pAbDm624Nr_2c+eJbPY5)r{+z*z!n1l7s4UW diff --git a/languages/openkaarten-frontend-plugin-nl_NL.po b/languages/openkaarten-frontend-plugin-nl_NL.po index 5ebca66..7bcc2a0 100644 --- a/languages/openkaarten-frontend-plugin-nl_NL.po +++ b/languages/openkaarten-frontend-plugin-nl_NL.po @@ -76,3 +76,50 @@ msgstr "kaart" msgctxt "block keyword" msgid "locations" msgstr "locaties" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:14 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:16 +msgid "Invalid URL" +msgstr "Ongeldige URL" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:59 +msgid "Error parsing nested JSON" +msgstr "Fout bij het parsen van geneste JSON" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:70 +msgid "Unexpected response format or 'datasets' is not an array." +msgstr "Onverwachte opbouw van antwoord, of 'datasets' is geen array." + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:76 +msgid "Fetching datasets failed" +msgstr "Het ophalen van datasets is mislukt" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:95 +msgid "Select the datalayers you want to display on the map" +msgstr "Selecteer de datalagen die u op de kaart wilt weergeven" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:95 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:156 +msgid "No datalayers found" +msgstr "Geen datalagen gevonden" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:111 +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:162 +msgid "No datalayers selected" +msgstr "Geen datalagen geselecteerd" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:131 +msgid "URL to rest-endpoint or Domain URL" +msgstr "URL naar rest-eindpunt of domein-URL" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:151 +msgid "Select datalayers:" +msgstr "Selecteer datalagen:" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:161 +msgid "Selected datalayers" +msgstr "Geselecteerde datalagen" + +#: src/blocks/owc-openkaarten/streetmap/assets/scripts/edit.js:166 +msgid "URL template for tile layer" +msgstr "URL-sjabloon voor tegel-laag" diff --git a/languages/openkaarten-frontend-plugin.pot b/languages/openkaarten-frontend-plugin.pot index 2742136..4be7e22 100644 --- a/languages/openkaarten-frontend-plugin.pot +++ b/languages/openkaarten-frontend-plugin.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2025-07-30T05:47:46+00:00\n" +"POT-Creation-Date: 2025-08-18T09:37:24+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.12.0\n" "X-Domain: openkaarten-frontend-plugin\n" diff --git a/package.json b/package.json index f9fc452..0a97f57 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "make-pot": "wp i18n make-pot . languages/openkaarten-frontend-plugin.pot --exclude=node_modules,build,languages", "update-po": "wp i18n update-po languages/openkaarten-frontend-plugin.pot languages/", "make-mo": "wp i18n make-mo languages/", - "make-json": "wp i18n make-json languages/", + "make-json": "wp i18n make-json languages/ --no-purge", "make-php": "wp i18n make-php languages/" }, "devDependencies": {