From d78992a872a556f3d38b91290d975adb2f4c9269 Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Wed, 2 Oct 2024 09:11:02 -0200 Subject: [PATCH 1/4] Better JSON detection in JS --- inc/parser/js.php | 8 ++++---- inc/translator/js.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/inc/parser/js.php b/inc/parser/js.php index 7e7272c..cc8c644 100644 --- a/inc/parser/js.php +++ b/inc/parser/js.php @@ -22,15 +22,15 @@ function wplng_parse_js( $js ) { } preg_match_all( - '#var\s(.*)\s?=\s?(\{.*\});#Ui', + '#(var\s|let\s|window\._)(.*)\s?=\s?(\{.*\});?#Ui', $js, $json ); - if ( ! empty( $json[1][0] ) && ! empty( $json[2][0] ) ) { + if ( ! empty( $json[2][0] ) && ! empty( $json[3][0] ) ) { - $var_name = $json[1][0]; - $var_json = $json[2][0]; + $var_name = $json[2][0]; + $var_json = $json[3][0]; $texts = wplng_parse_json( $var_json, diff --git a/inc/translator/js.php b/inc/translator/js.php index 7a6cd4a..b1d9e71 100644 --- a/inc/translator/js.php +++ b/inc/translator/js.php @@ -22,15 +22,15 @@ function wplng_translate_js( $js, $args = array() ) { $json = array(); preg_match_all( - '#var\s(.*)\s?=\s?(\{.*\});#Ui', + '#(var\s|let\s|window\._)(.*)\s?=\s?(\{.*\});?#Ui', $js, $json ); - if ( ! empty( $json[1][0] ) && ! empty( $json[2][0] ) ) { + if ( ! empty( $json[2][0] ) && ! empty( $json[3][0] ) ) { - $var_name = $json[1][0]; - $var_json = $json[2][0]; + $var_name = $json[2][0]; + $var_json = $json[3][0]; wplng_args_setup( $args ); From be0d903370cc4a62831629d422022c178ab409dc Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Wed, 2 Oct 2024 09:17:27 -0200 Subject: [PATCH 2/4] Add plugin compatiility: WF Cookie Consent --- data.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data.php b/data.php index bdf10c2..257a291 100644 --- a/data.php +++ b/data.php @@ -34,8 +34,14 @@ function wplng_data_json_to_translate() { array( 'wc_country_select_params', 'i18n_searching' ), array( 'wc_address_i18n_params', 'i18n_required_text' ), array( 'wc_address_i18n_params', 'i18n_optional_text' ), + // Plugin : YITH array( 'yith_wcwl_l10n', 'labels', 'cookie_disabled' ), + + // Plugin : WF Cookie Consent + array( 'wfCookieConsentSettings', 'wf_cookietext' ), + array( 'wfCookieConsentSettings', 'wf_dismisstext' ), + array( 'wfCookieConsentSettings', 'wf_linktext' ), ) ); } From 45420501df5127b2f243ba5cc200e5648d6121c8 Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Wed, 2 Oct 2024 10:21:46 -0200 Subject: [PATCH 3/4] Add youtube videos to the WordPress readme --- readme.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.txt b/readme.txt index 56ad22e..f83922b 100644 --- a/readme.txt +++ b/readme.txt @@ -28,6 +28,12 @@ The highlights: ✓ Open source, find [wpLingua on GitHub](https://github.com/julien-jacob/wplingua) ✓ And more! +### 🎬 6 minutes to translate your website + +[youtube https://www.youtube.com/watch?v=T1fTHnZhH-0] + +Video tutorial available in [Chinese](https://youtu.be/ET2ijgN3cUw?si=6L2_KlZJ6Dw3kOJq), [Danish](https://youtu.be/cxoMK5UamXA?si=sbaK-Fx8GAfsl8Bu), [English](https://youtu.be/T1fTHnZhH-0?si=rELV5g5I4i9KwVG0), [Finnish](https://youtu.be/niuBK79uK4Y?si=fKs6mvNqLCTliOIV), [French](https://youtu.be/No6PdIJrbrk?si=2w2yJERXIhdSfqFb), [German](https://youtu.be/TvyHn8n9zr4?si=FSWSHd8YkW17V07u), [Greek](https://youtu.be/MMrkmhzVrNM?si=A0BM0Mq-gBgIQ-rT), [Hindi](https://youtu.be/TCoaBMCusbE?si=eXACXPXZtAeC4J2P), [Italian](https://youtu.be/yYNkJqbFGeo?si=VBkJrNck4_kPma-0), [Japanese](https://youtu.be/H9jL6B9ZoRk?si=ZOoNKdxE67LMt4Sv), [Korean](https://youtu.be/FGi68qYvzWg?si=zNZKYPUvf12FNxCz), [Polish](https://youtu.be/QkQ8fn7XZkY?si=Z4aEfcVHs05_AOLS), [Portuguese](https://youtu.be/W8lGMYeE-wQ?si=SorUAE_AVW8-ezKE) and [Spanish](https://youtu.be/ePsri0sP99Y?si=l3JCik3Z-B0hg4CR). + ### 🔥 One free target language ### The first language translation is completely free for non-commercial websites. If your website is of a commercial nature (e-commerce, advertising, etc.), a commercial licence is available. From ac334115eb6ba6ed6e1dda188f0b10ee43f09a5e Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Wed, 2 Oct 2024 10:42:53 -0200 Subject: [PATCH 4/4] Update changelog and version number --- readme.txt | 8 +++++++- wplingua.php | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index f83922b..0e51bc1 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://wplingua.com/ Tags: translate, translation, multilingual, localization, language Requires at least: 6.0 Tested up to: 6.6 -Stable tag: 2.0.1 +Stable tag: 2.0.2 Requires PHP: 7.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -160,6 +160,12 @@ No, not at the moment but in the meantime, you can easily display the language s == Changelog == += 2.0.2 = + +* Better JSON detection in JavaScript +* Added plugin compatibility: WF Cookie Consent +* Add videos on WordPress description + = 2.0.1 = * Better SEO: Translate meta[name="description"] diff --git a/wplingua.php b/wplingua.php index dfad971..b0e1c52 100644 --- a/wplingua.php +++ b/wplingua.php @@ -7,7 +7,7 @@ * Author URI: https://wplingua.com/ * Text Domain: wplingua * Domain Path: /languages/ - * Version: 2.0.1 + * Version: 2.0.2 * Requires PHP: 7.4 * License: GPL v2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -24,7 +24,7 @@ define( 'WPLNG_API_URL', 'https://api.wplingua.com' ); define( 'WPLNG_API_VERSION', '2.0' ); define( 'WPLNG_API_SSLVERIFY', true ); -define( 'WPLNG_PLUGIN_VERSION', '2.0.1' ); +define( 'WPLNG_PLUGIN_VERSION', '2.0.2' ); define( 'WPLNG_PLUGIN_FILE', plugin_basename( __FILE__ ) ); define( 'WPLNG_PLUGIN_PATH', dirname( __FILE__ ) ); define( 'WPLNG_MAX_TRANSLATIONS', 256 );