Weglot Translate – Translate your WP website - Version 3.1.5

Version Description

(08/01/2020) = * Add: weglot_language_code_replace filter to use custom language code * Bugfix: Formatter on JSON source for untranslated WooComerce fields

Download this release

Release Info

Developer remyb92
Plugin Icon 128x128 Weglot Translate – Translate your WP website
Version 3.1.5
Comparing to
See all releases

Code changes from version 3.1.4 to 3.1.5

readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: translate, multilingual, language, translation, localization
4
  Requires at least: 4.5
5
  Tested up to: 5.3
6
  Requires PHP: 5.4
7
- Stable tag: 3.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -201,6 +201,10 @@ See changelog for upgrade changes.
201
 
202
  == Changelog ==
203
 
 
 
 
 
204
  = 3.1.4 (12/12/2019) =
205
  * Update back office style for WordPress 5.3
206
  * Fix: Flags SRC attribute with AMP
4
  Requires at least: 4.5
5
  Tested up to: 5.3
6
  Requires PHP: 5.4
7
+ Stable tag: 3.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
201
 
202
  == Changelog ==
203
 
204
+ = 3.1.5 (08/01/2020) =
205
+ * Add: weglot_language_code_replace filter to use custom language code
206
+ * Bugfix: Formatter on JSON source for untranslated WooComerce fields
207
+
208
  = 3.1.4 (12/12/2019) =
209
  * Update back office style for WordPress 5.3
210
  * Fix: Flags SRC attribute with AMP
src/actions/front/class-front-menu-weglot.php CHANGED
@@ -145,8 +145,11 @@ class Front_Menu_Weglot implements Hooks_Interface_Weglot {
145
  $language_item->ID = 'weglot-' . $item->ID . '-' . $language->getIso639();
146
  $language_item->title = $this->button_services->get_name_with_language_entry( $language );
147
  $language_item->attr_title = $language->getLocalName();
148
- $language_item->url = $this->custom_url_services->get_link_button_with_key_code( $language->getIso639() );
149
- ;
 
 
 
150
  $language_item->lang = $language->getIso639();
151
  $language_item->classes = array_merge( $classes, $add_classes );
152
  $language_item->menu_order += $offset + $i++;
145
  $language_item->ID = 'weglot-' . $item->ID . '-' . $language->getIso639();
146
  $language_item->title = $this->button_services->get_name_with_language_entry( $language );
147
  $language_item->attr_title = $language->getLocalName();
148
+
149
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
150
+ $l = isset($language_code_rewrited[$language->getIso639()]) ? $language_code_rewrited[$language->getIso639()]:$language->getIso639();
151
+ $language_item->url = $this->custom_url_services->get_link_button_with_key_code( $l );
152
+
153
  $language_item->lang = $language->getIso639();
154
  $language_item->classes = array_merge( $classes, $add_classes );
155
  $language_item->menu_order += $offset + $i++;
src/actions/front/class-search-weglot.php CHANGED
@@ -67,9 +67,12 @@ class Search_Weglot implements Hooks_Interface_Weglot {
67
  }
68
 
69
  try {
 
 
 
70
  $parser = $this->parser_services->get_parser();
71
  $this->old_search = $query->query_vars['s'];
72
- $this->new_search = $parser->translate( $query->query_vars[ 's' ], $current_language, $original_language ); //phpcs:ignore
73
 
74
  if ( empty( $this->new_search ) ) {
75
  return;
67
  }
68
 
69
  try {
70
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
71
+ $toTranslateLanguageIso = ($key = array_search($current_language,$language_code_rewrited)) ? $key:$current_language;
72
+
73
  $parser = $this->parser_services->get_parser();
74
  $this->old_search = $query->query_vars['s'];
75
+ $this->new_search = $parser->translate( $query->query_vars[ 's' ], $toTranslateLanguageIso, $original_language ); //phpcs:ignore
76
 
77
  if ( empty( $this->new_search ) ) {
78
  return;
src/actions/front/class-translate-page-weglot.php CHANGED
@@ -233,28 +233,31 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
233
  $custom_urls = $this->option_services->get_option( 'custom_urls' );
234
 
235
  // No language configured
236
- if ( ! isset( $custom_urls[ $current_language ] ) ) {
 
 
 
237
  $this->request_uri_default();
238
  return;
239
  }
240
 
241
- $key_slug = array_search( $slug_in_work, $custom_urls[ $current_language ] ); //phpcs:ignore
242
 
243
- // No custom URL for this language with this slug
244
- if ( ! isset( $custom_urls[ $current_language ][ $slug_in_work ] ) && false === $key_slug ) {
245
  $this->request_uri_default();
246
  return;
247
  }
248
 
249
  // Custom URL exist but not good slug
250
- if ( ! isset( $custom_urls[ $current_language ][ $slug_in_work ] ) ) {
251
  return;
252
  }
253
 
254
  $_SERVER['REQUEST_URI'] = str_replace(
255
  '/' . $current_language . '/',
256
  '/',
257
- str_replace( $slug_in_work, $custom_urls[ $current_language ][ $slug_in_work ], $_SERVER['REQUEST_URI'] ) //phpcs:ignore
258
  );
259
  }
260
 
233
  $custom_urls = $this->option_services->get_option( 'custom_urls' );
234
 
235
  // No language configured
236
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
237
+ $toTranslateLanguageIso = ($key = array_search($current_language,$language_code_rewrited)) ? $key:$current_language;
238
+
239
+ if ( ! isset( $custom_urls[ $toTranslateLanguageIso ] ) ) {
240
  $this->request_uri_default();
241
  return;
242
  }
243
 
244
+ $key_slug = array_search( $slug_in_work, $custom_urls[ $toTranslateLanguageIso ] ); //phpcs:ignore
245
 
246
+ // No custom URL for this language with this slug
247
+ if ( ! isset( $custom_urls[ $toTranslateLanguageIso ][ $slug_in_work ] ) && false === $key_slug ) {
248
  $this->request_uri_default();
249
  return;
250
  }
251
 
252
  // Custom URL exist but not good slug
253
+ if ( ! isset( $custom_urls[ $toTranslateLanguageIso ][ $slug_in_work ] ) ) {
254
  return;
255
  }
256
 
257
  $_SERVER['REQUEST_URI'] = str_replace(
258
  '/' . $current_language . '/',
259
  '/',
260
+ str_replace( $slug_in_work, $custom_urls[ $toTranslateLanguageIso ][ $slug_in_work ], $_SERVER['REQUEST_URI'] ) //phpcs:ignore
261
  );
262
  }
263
 
src/services/class-button-service-weglot.php CHANGED
@@ -115,20 +115,24 @@ class Button_Service_Weglot {
115
  $name = $this->get_name_with_language_entry( $current_language_entry );
116
 
117
  $uniq_id = 'wg' . uniqid( strtotime( 'now' ) ) . rand( 1, 1000 );
118
- $button_html .= sprintf( '<input id="%s" class="weglot_choice" type="checkbox" name="menu"/><label for="%s" class="wgcurrent wg-li weglot-lang weglot-language %s" data-code-language="%s"><span>%s</span></label>', esc_attr($uniq_id), esc_attr($uniq_id), esc_attr($flag_class . $current_language), esc_attr($current_language_entry->getIso639()), esc_html($name) );
119
 
120
  $button_html .= '<ul>';
121
 
122
  array_unshift( $destination_language, $original_language );
123
 
124
  foreach ( $destination_language as $key => $key_code ) {
125
- if ( $key_code === $current_language || $this->private_language_services->is_active_private_mode_for_lang( $key_code ) ) {
 
 
 
 
126
  continue;
127
  }
128
 
129
- $button_html .= sprintf( '<li class="wg-li weglot-lang weglot-language %s" data-code-language="%s">', $flag_class . $key_code, $key_code );
130
 
131
- $current_language_entry = $this->language_services->get_current_language_entry_from_key( $key_code );
132
  $name = $this->get_name_with_language_entry( $current_language_entry );
133
 
134
  $link_button = $this->custom_url_services->get_link_button_with_key_code( $key_code );
115
  $name = $this->get_name_with_language_entry( $current_language_entry );
116
 
117
  $uniq_id = 'wg' . uniqid( strtotime( 'now' ) ) . rand( 1, 1000 );
118
+ $button_html .= sprintf( '<input id="%s" class="weglot_choice" type="checkbox" name="menu"/><label for="%s" class="wgcurrent wg-li weglot-lang weglot-language %s" data-code-language="%s"><span>%s</span></label>', esc_attr($uniq_id), esc_attr($uniq_id), esc_attr($flag_class . $current_language_entry->getIso639()), esc_attr($current_language_entry->getIso639()), esc_html($name) );
119
 
120
  $button_html .= '<ul>';
121
 
122
  array_unshift( $destination_language, $original_language );
123
 
124
  foreach ( $destination_language as $key => $key_code ) {
125
+
126
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
127
+ $toTranslateLanguageIso = ($key = array_search($key_code,$language_code_rewrited)) ? $key:$key_code;
128
+
129
+ if ( $key_code === $current_language || $this->private_language_services->is_active_private_mode_for_lang( $toTranslateLanguageIso ) ) {
130
  continue;
131
  }
132
 
133
+ $button_html .= sprintf( '<li class="wg-li weglot-lang weglot-language %s" data-code-language="%s">', $flag_class . $toTranslateLanguageIso, $toTranslateLanguageIso );
134
 
135
+ $current_language_entry = $this->language_services->get_current_language_entry_from_key( $toTranslateLanguageIso );
136
  $name = $this->get_name_with_language_entry( $current_language_entry );
137
 
138
  $link_button = $this->custom_url_services->get_link_button_with_key_code( $key_code );
src/services/class-custom-url-service-weglot.php CHANGED
@@ -46,17 +46,20 @@ class Custom_Url_Service_Weglot {
46
  $slug_in_work = $request_without_language[ $index_entries ];
47
  $original_slug_in_work = $slug_in_work;
48
 
 
49
  if($current_language !== $original_language) {
50
- if ( isset( $custom_urls[ $current_language ] )) {
51
- $value_slug = array_key_exists($slug_in_work, $custom_urls[$current_language]) ? $custom_urls[$current_language][$slug_in_work] : false;
 
52
  if ( false !== $value_slug ) {
53
  $original_slug_in_work = $value_slug;
54
  }
55
  }
56
  }
57
 
58
- if ( isset( $custom_urls[ $key_code ] )) {
59
- $key_slug = array_search( $original_slug_in_work, $custom_urls[ $key_code ] ); //phpcs:ignore
 
60
  if ( false !== $key_slug ) {
61
  $url_lang = str_replace($slug_in_work, $key_slug, $url_lang);
62
  }
46
  $slug_in_work = $request_without_language[ $index_entries ];
47
  $original_slug_in_work = $slug_in_work;
48
 
49
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
50
  if($current_language !== $original_language) {
51
+ $toTranslateLanguageIso = ($key = array_search($current_language,$language_code_rewrited)) ? $key:$current_language;
52
+ if ( isset( $custom_urls[ $toTranslateLanguageIso ] )) {
53
+ $value_slug = array_key_exists($slug_in_work, $custom_urls[$toTranslateLanguageIso]) ? $custom_urls[$toTranslateLanguageIso][$slug_in_work] : false;
54
  if ( false !== $value_slug ) {
55
  $original_slug_in_work = $value_slug;
56
  }
57
  }
58
  }
59
 
60
+ $toTranslateLanguageIso = ($key = array_search($key_code,$language_code_rewrited)) ? $key:$key_code;
61
+ if ( isset( $custom_urls[ $toTranslateLanguageIso ] )) {
62
+ $key_slug = array_search( $original_slug_in_work, $custom_urls[ $toTranslateLanguageIso ] ); //phpcs:ignore
63
  if ( false !== $key_slug ) {
64
  $url_lang = str_replace($slug_in_work, $key_slug, $url_lang);
65
  }
src/services/class-email-translate-service-weglot.php CHANGED
@@ -35,6 +35,9 @@ class Email_Translate_Service_Weglot {
35
  public function translate_email( $args, $language ) {
36
  $api_key = $this->option_services->get_option( 'api_key' );
37
 
 
 
 
38
  if ( ! $api_key ) {
39
  return $args;
40
  }
@@ -46,12 +49,12 @@ class Email_Translate_Service_Weglot {
46
  $config = new ServerConfigProvider();
47
  $client = $this->parser_services->get_client();
48
  $parser = new Parser( $client, $config, $exclude_blocks );
49
- $translated_subject = $parser->translate( '<p>' . $args['subject'] . '</p>', $original_language, $language ); //phpcs:ignore
50
 
51
  $config = new ServerConfigProvider();
52
  $client = $this->parser_services->get_client();
53
  $parser = new Parser( $client, $config, $exclude_blocks );
54
- $translated_message = $parser->translate( $args['message'], $original_language, $language ); //phpcs:ignore
55
 
56
  return [
57
  'subject' => $translated_subject,
35
  public function translate_email( $args, $language ) {
36
  $api_key = $this->option_services->get_option( 'api_key' );
37
 
38
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
39
+ $toTranslateLanguageIso = ($key = array_search($language,$language_code_rewrited)) ? $key:$language;
40
+
41
  if ( ! $api_key ) {
42
  return $args;
43
  }
49
  $config = new ServerConfigProvider();
50
  $client = $this->parser_services->get_client();
51
  $parser = new Parser( $client, $config, $exclude_blocks );
52
+ $translated_subject = $parser->translate( '<p>' . $args['subject'] . '</p>', $original_language, $toTranslateLanguageIso ); //phpcs:ignore
53
 
54
  $config = new ServerConfigProvider();
55
  $client = $this->parser_services->get_client();
56
  $parser = new Parser( $client, $config, $exclude_blocks );
57
+ $translated_message = $parser->translate( $args['message'], $original_language, $toTranslateLanguageIso ); //phpcs:ignore
58
 
59
  return [
60
  'subject' => $translated_subject,
src/services/class-href-lang-service-weglot.php CHANGED
@@ -26,7 +26,7 @@ class Href_Lang_Service_Weglot {
26
  */
27
  public function generate_href_lang_tags() {
28
  $destination_languages = weglot_get_all_languages_configured();
29
- $render = '';
30
  if ( $this->private_language_service->private_mode_for_all_languages() ) {
31
  return apply_filters( 'weglot_href_lang', $render );
32
  }
@@ -38,7 +38,7 @@ class Href_Lang_Service_Weglot {
38
  }
39
 
40
  $url = $this->custom_url_services->get_link( $language, false );
41
- $render .= '<link rel="alternate" href="' . esc_url($url) . '" hreflang="' . $language . '"/>' . "\n";
42
  }
43
  } catch ( \Exception $e ) {
44
  $render = $this->request_url_services->get_weglot_url()->generateHrefLangsTags();
26
  */
27
  public function generate_href_lang_tags() {
28
  $destination_languages = weglot_get_all_languages_configured();
29
+ $render = "\n";
30
  if ( $this->private_language_service->private_mode_for_all_languages() ) {
31
  return apply_filters( 'weglot_href_lang', $render );
32
  }
38
  }
39
 
40
  $url = $this->custom_url_services->get_link( $language, false );
41
+ $render .= '<link rel="alternate" hreflang="' . $language . '" href="' . esc_url($url) . '"/>' . "\n";
42
  }
43
  } catch ( \Exception $e ) {
44
  $render = $this->request_url_services->get_weglot_url()->generateHrefLangsTags();
src/services/class-language-service-weglot.php CHANGED
@@ -78,7 +78,10 @@ class Language_Service_Weglot {
78
  * @return array
79
  */
80
  public function get_language( $key_code ) {
81
- return $this->get_languages_available()[ $key_code ];
 
 
 
82
  }
83
 
84
  /**
@@ -106,7 +109,6 @@ class Language_Service_Weglot {
106
  break;
107
  }
108
  }
109
-
110
  return $languages_object;
111
  }
112
 
@@ -119,6 +121,9 @@ class Language_Service_Weglot {
119
  public function get_current_language_entry_from_key( $key_code ) {
120
 
121
  $languages = $this->get_languages_available();
 
 
 
122
 
123
  if ( isset( $languages[ $key_code ] ) ) {
124
  $current_language_entry = $languages[ $key_code ];
78
  * @return array
79
  */
80
  public function get_language( $key_code ) {
81
+
82
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
83
+ $language = ($key = array_search($key_code,$language_code_rewrited)) ? $this->get_languages_available()[ $key ]:$this->get_languages_available()[ $key_code ];
84
+ return $language;
85
  }
86
 
87
  /**
109
  break;
110
  }
111
  }
 
112
  return $languages_object;
113
  }
114
 
121
  public function get_current_language_entry_from_key( $key_code ) {
122
 
123
  $languages = $this->get_languages_available();
124
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
125
+ if($key = array_search($key_code,$language_code_rewrited))
126
+ $key_code = $key;
127
 
128
  if ( isset( $languages[ $key_code ] ) ) {
129
  $current_language_entry = $languages[ $key_code ];
src/services/class-option-service-weglot.php CHANGED
@@ -420,6 +420,11 @@ class Option_Service_Weglot {
420
  */
421
  public function get_destination_languages() {
422
  $destination_languages = $this->get_option( 'destination_language' );
 
 
 
 
 
423
  return apply_filters( 'weglot_destination_languages', $destination_languages );
424
  }
425
 
420
  */
421
  public function get_destination_languages() {
422
  $destination_languages = $this->get_option( 'destination_language' );
423
+
424
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
425
+ $destination_languages = array_map(function ($v) use ($language_code_rewrited) {
426
+ return isset($language_code_rewrited[$v]) ? $language_code_rewrited[$v] : $v;
427
+ }, $destination_languages);
428
  return apply_filters( 'weglot_destination_languages', $destination_languages );
429
  }
430
 
src/services/class-redirect-service-weglot.php CHANGED
@@ -72,7 +72,7 @@ class Redirect_Service_Weglot {
72
  }
73
 
74
  if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { //phpcs:ignore
75
- $server_lang = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ); //phpcs:ignore
76
  } else {
77
  if ( isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) { // phpcs:ignore
78
  // Compatibility Cloudfare
72
  }
73
 
74
  if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { //phpcs:ignore
75
+ $server_lang = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, apply_filters('weglot_number_of_character_for_language',2) );
76
  } else {
77
  if ( isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) { // phpcs:ignore
78
  // Compatibility Cloudfare
src/services/class-replace-link-service-weglot.php CHANGED
@@ -54,9 +54,11 @@ class Replace_Link_Service_Weglot {
54
  $request_without_language = array_filter( explode( '/', $path ), 'strlen' );
55
  $index_entries = count( $request_without_language );
56
 
57
- if ( isset( $request_without_language[ $index_entries ] ) && ! is_admin() && ! empty( $custom_urls ) && isset( $custom_urls[ $current_language ] ) ) {
 
 
58
  $slug_in_work = $request_without_language[ $index_entries ];
59
- $key_slug = array_search( $slug_in_work, $custom_urls[ $current_language ] ); //phpcs:ignore
60
  if ( false !== $key_slug && ! empty( $key_slug ) ) {
61
  $path = str_replace( $slug_in_work, $key_slug, $path );
62
  }
54
  $request_without_language = array_filter( explode( '/', $path ), 'strlen' );
55
  $index_entries = count( $request_without_language );
56
 
57
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
58
+ $toTranslateLanguageIso = ($key = array_search($current_language,$language_code_rewrited)) ? $key:$current_language;
59
+ if ( isset( $request_without_language[ $index_entries ] ) && ! is_admin() && ! empty( $custom_urls ) && isset( $custom_urls[ $toTranslateLanguageIso ] ) ) {
60
  $slug_in_work = $request_without_language[ $index_entries ];
61
+ $key_slug = array_search( $slug_in_work, $custom_urls[ $toTranslateLanguageIso ] ); //phpcs:ignore
62
  if ( false !== $key_slug && ! empty( $key_slug ) ) {
63
  $path = str_replace( $slug_in_work, $key_slug, $path );
64
  }
src/services/class-translate-service-weglot.php CHANGED
@@ -82,15 +82,20 @@ class Translate_Service_Weglot {
82
  $parser = $this->parser_services->get_parser();
83
 
84
  try {
 
 
 
 
 
85
  switch ( $type ) {
86
  case 'json':
87
  $extraKeys = apply_filters( 'weglot_add_json_keys', array() );
88
- $translated_content = $parser->translate( $content, $this->original_language, $this->current_language, $extraKeys );
89
  $translated_content = json_encode( $this->replace_url_services->replace_link_in_json( json_decode( $translated_content, true ) ) );
90
  $translated_content = apply_filters( 'weglot_json_treat_page', $translated_content );
91
  return $translated_content;
92
  case 'html':
93
- $translated_content = $parser->translate( $content, $this->original_language, $this->current_language ); // phpcs:ignore
94
  $translated_content = apply_filters( 'weglot_html_treat_page', $translated_content );
95
  return $this->weglot_render_dom( $translated_content );
96
  default:
82
  $parser = $this->parser_services->get_parser();
83
 
84
  try {
85
+
86
+ $language_code_rewrited = apply_filters('weglot_language_code_replace' , array());
87
+ $toTranslateLanguageIso = ($key = array_search($this->current_language,$language_code_rewrited)) ? $key:$this->current_language;
88
+
89
+
90
  switch ( $type ) {
91
  case 'json':
92
  $extraKeys = apply_filters( 'weglot_add_json_keys', array() );
93
+ $translated_content = $parser->translate( $content, $this->original_language, $toTranslateLanguageIso, $extraKeys );
94
  $translated_content = json_encode( $this->replace_url_services->replace_link_in_json( json_decode( $translated_content, true ) ) );
95
  $translated_content = apply_filters( 'weglot_json_treat_page', $translated_content );
96
  return $translated_content;
97
  case 'html':
98
+ $translated_content = $parser->translate( $content, $this->original_language, $toTranslateLanguageIso ); // phpcs:ignore
99
  $translated_content = apply_filters( 'weglot_html_treat_page', $translated_content );
100
  return $this->weglot_render_dom( $translated_content );
101
  default:
src/third/maintenance/class-maintenance-active.php CHANGED
@@ -13,12 +13,12 @@ use WeglotWP\Models\Third_Active_Interface_Weglot;
13
  /**
14
  * Maintenance_Active
15
  *
16
- * @since 3.1.1
17
  */
18
  class Maintenance_Active implements Third_Active_Interface_Weglot {
19
 
20
  /**
21
- * @since 3.1.1
22
  * @return boolean
23
  *
24
  * Check if Maintenance plugin is active
13
  /**
14
  * Maintenance_Active
15
  *
16
+ * @since 3.1.4
17
  */
18
  class Maintenance_Active implements Third_Active_Interface_Weglot {
19
 
20
  /**
21
+ * @since 3.1.4
22
  * @return boolean
23
  *
24
  * Check if Maintenance plugin is active
src/third/maintenance/class-maintenance-tracking.php CHANGED
@@ -12,12 +12,12 @@ use WeglotWP\Models\Hooks_Interface_Weglot;
12
  /**
13
  * Maintenance_Tracking
14
  *
15
- * @since 3.1.1
16
  */
17
  class Maintenance_Tracking implements Hooks_Interface_Weglot {
18
 
19
  /**
20
- * @since 3.1.1
21
  * @return void
22
  */
23
  public function __construct() {
@@ -25,7 +25,7 @@ class Maintenance_Tracking implements Hooks_Interface_Weglot {
25
  }
26
 
27
  /**
28
- * @since 3.1.1
29
  * @see Hooks_Interface_Weglot
30
  * @return void
31
  */
@@ -43,7 +43,7 @@ class Maintenance_Tracking implements Hooks_Interface_Weglot {
43
 
44
 
45
  /**
46
- * @since 3.1.1
47
  * @return void
48
  */
49
  public function weglot_maintenance_tracking( $options_available ) {
12
  /**
13
  * Maintenance_Tracking
14
  *
15
+ * @since 3.1.4
16
  */
17
  class Maintenance_Tracking implements Hooks_Interface_Weglot {
18
 
19
  /**
20
+ * @since 3.1.4
21
  * @return void
22
  */
23
  public function __construct() {
25
  }
26
 
27
  /**
28
+ * @since 3.1.4
29
  * @see Hooks_Interface_Weglot
30
  * @return void
31
  */
43
 
44
 
45
  /**
46
+ * @since 3.1.4
47
  * @return void
48
  */
49
  public function weglot_maintenance_tracking( $options_available ) {
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit0bd32020b44e0c8a75f811f996d6668d::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit5b44db1e69c1ba973447e0369e60de5d::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit0bd32020b44e0c8a75f811f996d6668d
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit0bd32020b44e0c8a75f811f996d6668d
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit0bd32020b44e0c8a75f811f996d6668d', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit0bd32020b44e0c8a75f811f996d6668d', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit0bd32020b44e0c8a75f811f996d6668d
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire0bd32020b44e0c8a75f811f996d6668d($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire0bd32020b44e0c8a75f811f996d6668d($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit5b44db1e69c1ba973447e0369e60de5d
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit5b44db1e69c1ba973447e0369e60de5d', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit5b44db1e69c1ba973447e0369e60de5d', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire5b44db1e69c1ba973447e0369e60de5d($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire5b44db1e69c1ba973447e0369e60de5d($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
@@ -57,10 +57,10 @@ class ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d
57
  public static function getInitializer(ClassLoader $loader)
58
  {
59
  return \Closure::bind(function () use ($loader) {
60
- $loader->prefixLengthsPsr4 = ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d::$prefixLengthsPsr4;
61
- $loader->prefixDirsPsr4 = ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d::$prefixDirsPsr4;
62
- $loader->prefixesPsr0 = ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d::$prefixesPsr0;
63
- $loader->classMap = ComposerStaticInit0bd32020b44e0c8a75f811f996d6668d::$classMap;
64
 
65
  }, null, ClassLoader::class);
66
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
57
  public static function getInitializer(ClassLoader $loader)
58
  {
59
  return \Closure::bind(function () use ($loader) {
60
+ $loader->prefixLengthsPsr4 = ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d::$prefixLengthsPsr4;
61
+ $loader->prefixDirsPsr4 = ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d::$prefixDirsPsr4;
62
+ $loader->prefixesPsr0 = ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d::$prefixesPsr0;
63
+ $loader->classMap = ComposerStaticInit5b44db1e69c1ba973447e0369e60de5d::$classMap;
64
 
65
  }, null, ClassLoader::class);
66
  }
vendor/composer/installed.json CHANGED
@@ -171,17 +171,17 @@
171
  },
172
  {
173
  "name": "weglot/weglot-php",
174
- "version": "1.0.2",
175
- "version_normalized": "1.0.2.0",
176
  "source": {
177
  "type": "git",
178
  "url": "https://github.com/weglot/weglot-php.git",
179
- "reference": "18e643a5178b2cf1b53293b58850793a0b2ab587"
180
  },
181
  "dist": {
182
  "type": "zip",
183
- "url": "https://api.github.com/repos/weglot/weglot-php/zipball/18e643a5178b2cf1b53293b58850793a0b2ab587",
184
- "reference": "18e643a5178b2cf1b53293b58850793a0b2ab587",
185
  "shasum": ""
186
  },
187
  "require": {
@@ -194,7 +194,7 @@
194
  "codeception/codeception": "^2.4",
195
  "vlucas/phpdotenv": "^2.4"
196
  },
197
- "time": "2019-12-16T09:50:51+00:00",
198
  "type": "library",
199
  "installation-source": "dist",
200
  "autoload": {
171
  },
172
  {
173
  "name": "weglot/weglot-php",
174
+ "version": "1.0.3",
175
+ "version_normalized": "1.0.3.0",
176
  "source": {
177
  "type": "git",
178
  "url": "https://github.com/weglot/weglot-php.git",
179
+ "reference": "d6ff95d5a90be94da5ec2dbc19b7620a9699f2af"
180
  },
181
  "dist": {
182
  "type": "zip",
183
+ "url": "https://api.github.com/repos/weglot/weglot-php/zipball/d6ff95d5a90be94da5ec2dbc19b7620a9699f2af",
184
+ "reference": "d6ff95d5a90be94da5ec2dbc19b7620a9699f2af",
185
  "shasum": ""
186
  },
187
  "require": {
194
  "codeception/codeception": "^2.4",
195
  "vlucas/phpdotenv": "^2.4"
196
  },
197
+ "time": "2019-12-30T13:28:21+00:00",
198
  "type": "library",
199
  "installation-source": "dist",
200
  "autoload": {
vendor/weglot/weglot-php/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
 
7
  ## [Unreleased]
8
 
 
 
 
 
9
  ## [1.0.2] - 2019-12-16
10
  ### Changed
11
  - Fixed formatter on text regex when it contain '#'
6
 
7
  ## [Unreleased]
8
 
9
+ ## [1.0.3] - 2019-12-16
10
+ ### Changed
11
+ - Fixed formatter on JSON source, only apply previous change to TEXT regex
12
+
13
  ## [1.0.2] - 2019-12-16
14
  ### Changed
15
  - Fixed formatter on text regex when it contain '#'
vendor/weglot/weglot-php/src/Parser/Parser.php CHANGED
@@ -478,7 +478,12 @@ class Parser
478
  $source = $tree['dom']->save();
479
  foreach ($tree['regexes'] as $regex) {
480
  $translatedRegex = $this->formatters($regex['source'], $translateEntry, $regex, $index);
481
- $source = preg_replace( '#\b' . preg_quote( $regex['source'], '#' ) . '\b#' , $translatedRegex, $source);
 
 
 
 
 
482
  }
483
  }
484
  return $source;
478
  $source = $tree['dom']->save();
479
  foreach ($tree['regexes'] as $regex) {
480
  $translatedRegex = $this->formatters($regex['source'], $translateEntry, $regex, $index);
481
+ if($regex['type'] === SourceType::SOURCE_TEXT) {
482
+ $source = preg_replace( '#\b' . preg_quote( $regex['source'], '#' ) . '\b#' , $translatedRegex, $source);
483
+ }
484
+ else {
485
+ $source = str_replace($regex['source'] , $translatedRegex, $source);
486
+ }
487
  }
488
  }
489
  return $source;
weglot-functions.php CHANGED
@@ -67,7 +67,7 @@ function weglot_get_destination_languages() {
67
  * @return array
68
  */
69
  function weglot_get_all_languages_configured() {
70
- $destinations = weglot_get_destination_language();
71
  $original = weglot_get_original_language();
72
  array_unshift( $destinations, $original );
73
  return $destinations;
67
  * @return array
68
  */
69
  function weglot_get_all_languages_configured() {
70
+ $destinations = weglot_get_destination_languages();
71
  $original = weglot_get_original_language();
72
  array_unshift( $destinations, $original );
73
  return $destinations;
weglot.php CHANGED
@@ -7,7 +7,7 @@ Author: Weglot Translate team
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
- Version: 3.1.4
11
  */
12
 
13
  /**
@@ -22,7 +22,7 @@ if ( ! defined('ABSPATH')) {
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
- define('WEGLOT_VERSION', '3.1.4');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
+ Version: 3.1.5
11
  */
12
 
13
  /**
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
+ define('WEGLOT_VERSION', '3.1.5');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );