Lingotek Translation - Version 1.2.2

Version Description

(2016-7-8) =

  • Fixed a bug that prevented translation of content into Japanese
  • Fixed the In-Context Review redirect
  • Added support for content download during intermediate workflow steps
Download this release

Release Info

Developer erichie
Plugin Icon 128x128 Lingotek Translation
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

include/api.php CHANGED
@@ -183,7 +183,7 @@ class Lingotek_API extends Lingotek_HTTP {
183
  }
184
  }
185
 
186
- return !is_wp_error($response) && 204 == wp_remote_retrieve_response_code($response);
187
  }
188
 
189
  /*
@@ -288,6 +288,7 @@ class Lingotek_API extends Lingotek_HTTP {
288
  * @return bool true if the request succeeded
289
  */
290
  public function request_translation($id, $locale, $args = array(), $wp_id = null) {
 
291
  $args = wp_parse_args($args, array('workflow_id' => $this->defaults['workflow_id']));
292
  $args = array_merge(array('locale_code' => $locale), $args);
293
  $response = $this->post($this->api_url . '/document/' . $id . '/translation', $args);
@@ -328,6 +329,7 @@ class Lingotek_API extends Lingotek_HTTP {
328
  * @return string|bool the translation, false if there is none
329
  */
330
  public function get_translation($doc_id, $locale, $wp_id = null) {
 
331
  $response = $this->get(add_query_arg(array('locale_code' => $locale, 'auto_format' => 'true') , $this->api_url . '/document/' . $doc_id . '/content'));
332
 
333
  if ($wp_id) {
183
  }
184
  }
185
 
186
+ return !is_wp_error($response) && (204 == wp_remote_retrieve_response_code($response) || 202 == wp_remote_retrieve_response_code($response));
187
  }
188
 
189
  /*
288
  * @return bool true if the request succeeded
289
  */
290
  public function request_translation($id, $locale, $args = array(), $wp_id = null) {
291
+ $locale = Lingotek::map_to_lingotek_locale($locale);
292
  $args = wp_parse_args($args, array('workflow_id' => $this->defaults['workflow_id']));
293
  $args = array_merge(array('locale_code' => $locale), $args);
294
  $response = $this->post($this->api_url . '/document/' . $id . '/translation', $args);
329
  * @return string|bool the translation, false if there is none
330
  */
331
  public function get_translation($doc_id, $locale, $wp_id = null) {
332
+ $locale = Lingotek::map_to_lingotek_locale($locale);
333
  $response = $this->get(add_query_arg(array('locale_code' => $locale, 'auto_format' => 'true') , $this->api_url . '/document/' . $doc_id . '/content'));
334
 
335
  if ($wp_id) {
include/callback.php CHANGED
@@ -39,7 +39,7 @@ class Lingotek_Callback {
39
 
40
  // posts
41
  if (post_type_exists($document->type)) {
42
- if ($id = $document->pllm->get_post($document->source, $locale)) {
43
  wp_redirect(get_permalink($id), 301);
44
  exit();
45
  }
@@ -66,13 +66,13 @@ class Lingotek_Callback {
66
  $document->request_translations();
67
  }
68
 
69
- if (isset($_GET['locale']) && 'target' == $_GET['type']) {
70
  // We will need access to PLL_Admin_Sync::copy_post_metas
71
  global $polylang;
72
  $polylang->sync = new PLL_Admin_Sync($polylang);
73
 
74
  $locale = Lingotek::map_to_wp_locale($_GET['locale']); // map to WP locale
75
- $document->is_automatic_download($locale) ? $document->create_translation($locale, true) : $document->translation_ready($locale);
76
  }
77
 
78
  status_header(200); // useless as it the default value
39
 
40
  // posts
41
  if (post_type_exists($document->type)) {
42
+ if ($id = PLL()->model->post->get($document->source, $locale)) {
43
  wp_redirect(get_permalink($id), 301);
44
  exit();
45
  }
66
  $document->request_translations();
67
  }
68
 
69
+ if ((isset($_GET['locale']) && 'target' == $_GET['type']) || (isset($_GET['locale']) && $_GET['type'] == 'phase')) {
70
  // We will need access to PLL_Admin_Sync::copy_post_metas
71
  global $polylang;
72
  $polylang->sync = new PLL_Admin_Sync($polylang);
73
 
74
  $locale = Lingotek::map_to_wp_locale($_GET['locale']); // map to WP locale
75
+ $document->is_automatic_download($locale) ? $document->create_translation($locale, true, $_GET['type']) : $document->translation_ready($locale);
76
  }
77
 
78
  status_header(200); // useless as it the default value
include/group-post.php CHANGED
@@ -286,7 +286,7 @@ class Lingotek_Group_Post extends Lingotek_Group {
286
  *
287
  * @param string $locale
288
  */
289
- public function create_translation($locale, $automatic = false) {
290
  // Removes content sanitization so YouTube videos, links, etc don't get removed when inserting translations
291
  remove_filter('content_save_pre', 'wp_filter_post_kses');
292
  remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
@@ -323,7 +323,8 @@ class Lingotek_Group_Post extends Lingotek_Group {
323
  }
324
 
325
  // create new translation
326
- else if ($this->translations[$locale] == 'ready' || $automatic) {
 
327
  $content_type_options = get_option('lingotek_content_type');
328
  if (!isset($content_type_options[$post->post_type]['fields']['post_name'])) {
329
  unset($post->post_name); // forces the creation of a new default slug if not translated by Lingotek
@@ -347,6 +348,9 @@ class Lingotek_Group_Post extends Lingotek_Group {
347
  $tr_lang = $this->pllm->get_language($locale);
348
  PLL()->model->post->set_language($tr_id, $tr_lang);
349
  $this->safe_translation_status_update($locale, 'current', array($tr_lang->slug => $tr_id));
 
 
 
350
  wp_set_object_terms($tr_id, $this->term_id, 'post_translations');
351
 
352
  // Copies categories and tags
286
  *
287
  * @param string $locale
288
  */
289
+ public function create_translation($locale, $automatic = false, $callback_type = NULL) {
290
  // Removes content sanitization so YouTube videos, links, etc don't get removed when inserting translations
291
  remove_filter('content_save_pre', 'wp_filter_post_kses');
292
  remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
323
  }
324
 
325
  // create new translation
326
+ else if (($this->translations[$locale] == 'ready' || $this->translations[$locale] == 'pending') || $automatic) {
327
+ $starting_status = $this->translations[$locale];
328
  $content_type_options = get_option('lingotek_content_type');
329
  if (!isset($content_type_options[$post->post_type]['fields']['post_name'])) {
330
  unset($post->post_name); // forces the creation of a new default slug if not translated by Lingotek
348
  $tr_lang = $this->pllm->get_language($locale);
349
  PLL()->model->post->set_language($tr_id, $tr_lang);
350
  $this->safe_translation_status_update($locale, 'current', array($tr_lang->slug => $tr_id));
351
+ if ($starting_status == 'pending' && $callback_type == 'phase') {
352
+ $this->safe_translation_status_update($locale, 'pending');
353
+ }
354
  wp_set_object_terms($tr_id, $this->term_id, 'post_translations');
355
 
356
  // Copies categories and tags
lingotek.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin name: Lingotek Translation
4
  Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin
5
- Version: 1.2.1
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
@@ -15,7 +15,7 @@ GitHub Plugin URI: https://github.com/lingotek/lingotek-translation
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
- define('LINGOTEK_VERSION', '1.2.1'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.8');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  define('LINGOTEK_PLUGIN_SLUG', 'lingotek-translation');// plugin slug (should match above meta: Text Domain)
2
  /*
3
  Plugin name: Lingotek Translation
4
  Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin
5
+ Version: 1.2.2
6
  Author: Lingotek and Frédéric Demarle
7
  Author uri: http://lingotek.com
8
  Description: Lingotek offers convenient cloud-based localization and translation.
15
  if (!function_exists('add_action'))
16
  exit();
17
 
18
+ define('LINGOTEK_VERSION', '1.2.2'); // plugin version (should match above meta)
19
  define('LINGOTEK_MIN_PLL_VERSION', '1.8');
20
  define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
21
  define('LINGOTEK_PLUGIN_SLUG', 'lingotek-translation');// plugin slug (should match above meta: Text Domain)
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: chouby, smithworx, erichie
3
  Donate link: http://lingotek.com/
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
- Tested up to: 4.4
7
- Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -122,6 +122,12 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
 
125
  = 1.2.1 (2016-5-26) =
126
 
127
  * Added support for the Share Slugs feature in Polylang Pro
3
  Donate link: http://lingotek.com/
4
  Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
5
  Requires at least: 3.8
6
+ Tested up to: 4.5
7
+ Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
122
 
123
  == Changelog ==
124
 
125
+ = 1.2.2 (2016-7-8) =
126
+
127
+ * Fixed a bug that prevented translation of content into Japanese
128
+ * Fixed the In-Context Review redirect
129
+ * Added support for content download during intermediate workflow steps
130
+
131
  = 1.2.1 (2016-5-26) =
132
 
133
  * Added support for the Share Slugs feature in Polylang Pro