Version Description
(2018-2-23) =
- Added ability to download translations at any point of the content's workflow
Download this release
Release Info
Developer | erichie |
Plugin | Lingotek Translation |
Version | 1.3.7 |
Comparing to | |
See all releases |
Code changes from version 1.3.6 to 1.3.7
- admin/actions.php +14 -1
- css/admin.css +11 -0
- include/api.php +22 -4
- include/group-post.php +12 -3
- include/group.php +7 -2
- js/updater.js +15 -0
- lingotek.php +2 -2
- readme.txt +6 -2
admin/actions.php
CHANGED
@@ -118,6 +118,11 @@ abstract class Lingotek_Actions {
|
|
118 |
'icon' => 'download',
|
119 |
),
|
120 |
|
|
|
|
|
|
|
|
|
|
|
121 |
'current' => array(
|
122 |
'title' => __( 'Current', 'lingotek-translation' ),
|
123 |
'icon' => 'edit',
|
@@ -227,6 +232,10 @@ abstract class Lingotek_Actions {
|
|
227 |
*/
|
228 |
public static function display_icon( $name, $link, $additional = '' ) {
|
229 |
self::link_to_settings_if_not_connected($link);
|
|
|
|
|
|
|
|
|
230 |
return sprintf('<a class="lingotek-color dashicons dashicons-%s dashicons-%s-lingotek" title="%s" href="%s"%s></a>',
|
231 |
self::$icons[ $name ]['icon'], self::$icons[ $name ]['icon'], self::$icons[ $name ]['title'], esc_url( $link ), $additional);
|
232 |
}
|
@@ -405,6 +414,10 @@ abstract class Lingotek_Actions {
|
|
405 |
$actions['lingotek-download'] = $this->get_action_link( array( 'document_id' => $document->document_id, 'action' => 'download' ) );
|
406 |
}
|
407 |
|
|
|
|
|
|
|
|
|
408 |
// need to request translations ?
|
409 |
$language = $this->get_language( $document->source );
|
410 |
$all_locales = array_flip( $this->pllm->get_languages_list( array( 'fields' => 'locale' ) ) );
|
@@ -550,7 +563,7 @@ abstract class Lingotek_Actions {
|
|
550 |
|
551 |
if ( $document = $this->lgtm->get_group( $this->type, filter_input( INPUT_POST, 'id' ) ) ) {
|
552 |
foreach ( $document->translations as $locale => $status ) {
|
553 |
-
if ( 'pending' === $status || 'ready' === $status ) {
|
554 |
$document->create_translation( $locale );
|
555 |
}
|
556 |
}
|
118 |
'icon' => 'download',
|
119 |
),
|
120 |
|
121 |
+
'interim' => array(
|
122 |
+
'title' => __('Interim Translation Downloaded', 'lingotek-translation'),
|
123 |
+
'icon' => 'edit'
|
124 |
+
),
|
125 |
+
|
126 |
'current' => array(
|
127 |
'title' => __( 'Current', 'lingotek-translation' ),
|
128 |
'icon' => 'edit',
|
232 |
*/
|
233 |
public static function display_icon( $name, $link, $additional = '' ) {
|
234 |
self::link_to_settings_if_not_connected($link);
|
235 |
+
if ($name == 'interim') {
|
236 |
+
return sprintf('<a class="lingotek-interim-color dashicons dashicons-%s dashicons-%s-lingotek" title="%s" href="%s"%s></a>',
|
237 |
+
self::$icons[ $name ]['icon'], self::$icons[ $name ]['icon'], self::$icons[ $name ]['title'], esc_url( $link ), $additional);
|
238 |
+
}
|
239 |
return sprintf('<a class="lingotek-color dashicons dashicons-%s dashicons-%s-lingotek" title="%s" href="%s"%s></a>',
|
240 |
self::$icons[ $name ]['icon'], self::$icons[ $name ]['icon'], self::$icons[ $name ]['title'], esc_url( $link ), $additional);
|
241 |
}
|
414 |
$actions['lingotek-download'] = $this->get_action_link( array( 'document_id' => $document->document_id, 'action' => 'download' ) );
|
415 |
}
|
416 |
|
417 |
+
if ($document->has_translation_status('interim')) {
|
418 |
+
$actions['lingotek-status'] = $this->get_action_link( array( 'document_id' => $document->document_id, 'action' => 'status' ) );
|
419 |
+
}
|
420 |
+
|
421 |
// need to request translations ?
|
422 |
$language = $this->get_language( $document->source );
|
423 |
$all_locales = array_flip( $this->pllm->get_languages_list( array( 'fields' => 'locale' ) ) );
|
563 |
|
564 |
if ( $document = $this->lgtm->get_group( $this->type, filter_input( INPUT_POST, 'id' ) ) ) {
|
565 |
foreach ( $document->translations as $locale => $status ) {
|
566 |
+
if ( 'pending' === $status || 'ready' === $status || 'interim' === $status || 'current' === $status) {
|
567 |
$document->create_translation( $locale );
|
568 |
}
|
569 |
}
|
css/admin.css
CHANGED
@@ -43,6 +43,17 @@ a.lingotek-color:hover {
|
|
43 |
color: #ffab42; /* lighter orange */
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
a.dashicons {
|
47 |
cursor: pointer;
|
48 |
}
|
43 |
color: #ffab42; /* lighter orange */
|
44 |
}
|
45 |
|
46 |
+
.lingotek-interim-color {
|
47 |
+
color: #b0b0b0;
|
48 |
+
}
|
49 |
+
a.lingotek-interim-color {
|
50 |
+
color: #b0b0b0;
|
51 |
+
}
|
52 |
+
|
53 |
+
a.lingotek-interim-color:hover {
|
54 |
+
color: #dbdbdb;
|
55 |
+
}
|
56 |
+
|
57 |
a.dashicons {
|
58 |
cursor: pointer;
|
59 |
}
|
include/api.php
CHANGED
@@ -272,6 +272,27 @@ class Lingotek_API extends Lingotek_HTTP {
|
|
272 |
return $content;
|
273 |
}
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
/**
|
276 |
* check translations status of a document
|
277 |
*
|
@@ -476,10 +497,7 @@ class Lingotek_API extends Lingotek_HTTP {
|
|
476 |
*/
|
477 |
public function get_translation($doc_id, $locale, $wp_id = null) {
|
478 |
$locale = Lingotek::map_to_lingotek_locale($locale);
|
479 |
-
|
480 |
-
if (isset($statuses[$locale]) && $statuses[$locale] != 100) {
|
481 |
-
return false;
|
482 |
-
}
|
483 |
$response = $this->get(add_query_arg(array('locale_code' => $locale, 'auto_format' => 'true') , $this->api_url . '/document/' . $doc_id . '/content'));
|
484 |
|
485 |
if ($wp_id) {
|
272 |
return $content;
|
273 |
}
|
274 |
|
275 |
+
/**
|
276 |
+
* check translations status of a specific locale for a document
|
277 |
+
*
|
278 |
+
* @since 0.1
|
279 |
+
*
|
280 |
+
* @param string $doc_id document id
|
281 |
+
* @param string $locale locale
|
282 |
+
* @return int with locale percent_complete
|
283 |
+
*/
|
284 |
+
public function get_translation_status($doc_id, $locale) {
|
285 |
+
$locale = Lingotek::map_to_lingotek_locale($locale);
|
286 |
+
$status = -1;
|
287 |
+
$response = $this->get($this->api_url . '/document/' . $doc_id . '/translation/' . $locale);
|
288 |
+
if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
|
289 |
+
$b = json_decode(wp_remote_retrieve_body($response));
|
290 |
+
$status = $b->properties->percent_complete;
|
291 |
+
}
|
292 |
+
|
293 |
+
return $status;
|
294 |
+
}
|
295 |
+
|
296 |
/**
|
297 |
* check translations status of a document
|
298 |
*
|
497 |
*/
|
498 |
public function get_translation($doc_id, $locale, $wp_id = null) {
|
499 |
$locale = Lingotek::map_to_lingotek_locale($locale);
|
500 |
+
|
|
|
|
|
|
|
501 |
$response = $this->get(add_query_arg(array('locale_code' => $locale, 'auto_format' => 'true') , $this->api_url . '/document/' . $doc_id . '/content'));
|
502 |
|
503 |
if ($wp_id) {
|
include/group-post.php
CHANGED
@@ -294,6 +294,10 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
294 |
|
295 |
$client = new Lingotek_API();
|
296 |
|
|
|
|
|
|
|
|
|
297 |
$translation = $client->get_translation($this->document_id, $locale, $this->source);
|
298 |
if (!$translation || $this->translation_not_ready( json_decode($translation, true) )) return; // If the request failed.
|
299 |
$translation = json_decode($translation, true); // wp_insert_post expects array
|
@@ -322,7 +326,12 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
322 |
}
|
323 |
|
324 |
wp_update_post($tr_post);
|
325 |
-
|
|
|
|
|
|
|
|
|
|
|
326 |
}
|
327 |
|
328 |
// create new translation
|
@@ -351,8 +360,8 @@ class Lingotek_Group_Post extends Lingotek_Group {
|
|
351 |
$tr_lang = $this->pllm->get_language($locale);
|
352 |
PLL()->model->post->set_language($tr_id, $tr_lang);
|
353 |
$this->safe_translation_status_update($locale, 'current', array($tr_lang->slug => $tr_id));
|
354 |
-
if ($starting_status == 'pending'
|
355 |
-
$this->safe_translation_status_update($locale, '
|
356 |
}
|
357 |
wp_set_object_terms($tr_id, $this->term_id, 'post_translations');
|
358 |
|
294 |
|
295 |
$client = new Lingotek_API();
|
296 |
|
297 |
+
$status = $client->get_translation_status($this->document_id, $locale);
|
298 |
+
if ($status === -1) {
|
299 |
+
return;
|
300 |
+
}
|
301 |
$translation = $client->get_translation($this->document_id, $locale, $this->source);
|
302 |
if (!$translation || $this->translation_not_ready( json_decode($translation, true) )) return; // If the request failed.
|
303 |
$translation = json_decode($translation, true); // wp_insert_post expects array
|
326 |
}
|
327 |
|
328 |
wp_update_post($tr_post);
|
329 |
+
if ($status !== 100) {
|
330 |
+
$this->safe_translation_status_update($locale, 'interim');
|
331 |
+
}
|
332 |
+
else {
|
333 |
+
$this->safe_translation_status_update($locale, 'current');
|
334 |
+
}
|
335 |
}
|
336 |
|
337 |
// create new translation
|
360 |
$tr_lang = $this->pllm->get_language($locale);
|
361 |
PLL()->model->post->set_language($tr_id, $tr_lang);
|
362 |
$this->safe_translation_status_update($locale, 'current', array($tr_lang->slug => $tr_id));
|
363 |
+
if ($starting_status == 'pending') {
|
364 |
+
$this->safe_translation_status_update($locale, 'interim');
|
365 |
}
|
366 |
wp_set_object_terms($tr_id, $this->term_id, 'post_translations');
|
367 |
|
include/group.php
CHANGED
@@ -294,10 +294,15 @@ abstract class Lingotek_Group {
|
|
294 |
foreach ($translations as $lingotek_locale => $percent)
|
295 |
{
|
296 |
if (!isset($lingotek_locale_to_pll_locale[$lingotek_locale])) { continue; }
|
|
|
297 |
$wp_locale = $lingotek_locale_to_pll_locale[$lingotek_locale];
|
298 |
-
if ($translations[$lingotek_locale] < 100) {
|
299 |
$this->translations[$wp_locale] = 'pending';
|
300 |
-
}
|
|
|
|
|
|
|
|
|
301 |
$this->translations[$wp_locale] = 'ready';
|
302 |
}
|
303 |
}
|
294 |
foreach ($translations as $lingotek_locale => $percent)
|
295 |
{
|
296 |
if (!isset($lingotek_locale_to_pll_locale[$lingotek_locale])) { continue; }
|
297 |
+
|
298 |
$wp_locale = $lingotek_locale_to_pll_locale[$lingotek_locale];
|
299 |
+
if ($translations[$lingotek_locale] < 100 && $this->translations[$wp_locale] !== 'interim') {
|
300 |
$this->translations[$wp_locale] = 'pending';
|
301 |
+
}
|
302 |
+
else if ($this->translations[$wp_locale] === 'interim' && $translations[$lingotek_locale] === 100) {
|
303 |
+
$this->translations[$wp_locale] = 'ready';
|
304 |
+
}
|
305 |
+
else if ((!isset($this->translations[$wp_locale])) || ($this->translations[$wp_locale] !== 'current') && $this->translations[$wp_locale] !== 'interim') {
|
306 |
$this->translations[$wp_locale] = 'ready';
|
307 |
}
|
308 |
}
|
js/updater.js
CHANGED
@@ -86,6 +86,10 @@ jQuery(document).ready(function($) {
|
|
86 |
updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
|
87 |
updateWorkbenchIcon(td, data, key, locale, 'In Progress', 'clock');
|
88 |
break;
|
|
|
|
|
|
|
|
|
89 |
case 'importing':
|
90 |
$(td).find('.pll_icon_edit').remove();
|
91 |
updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
|
@@ -170,6 +174,17 @@ jQuery(document).ready(function($) {
|
|
170 |
$(td).prepend(request_link);
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
function updateGenericBulkLink(tr, data, key, action, title, text){
|
174 |
var row_actions = $(tr).find('.row-actions');
|
175 |
if($(row_actions).find('.lingotek-' + action).length === 0){
|
86 |
updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
|
87 |
updateWorkbenchIcon(td, data, key, locale, 'In Progress', 'clock');
|
88 |
break;
|
89 |
+
case 'interim':
|
90 |
+
updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
|
91 |
+
updateInterimIcon(td, data, key, locale);
|
92 |
+
break;
|
93 |
case 'importing':
|
94 |
$(td).find('.pll_icon_edit').remove();
|
95 |
updateGenericBulkLink(tr, data, key, 'status' , 'Update translations status of this item in Lingotek TMS', 'Update translations status ');
|
174 |
$(td).prepend(request_link);
|
175 |
}
|
176 |
|
177 |
+
function updateInterimIcon(td, data, key, locale) {
|
178 |
+
$(td).find('.lingotek-professional-icon').remove();
|
179 |
+
var icon = 'edit';
|
180 |
+
$(td).find('.lingotek-interim-color').remove();
|
181 |
+
var request_link = $('<a></a>').attr('href', data[key][locale]['workbench_link'])
|
182 |
+
.attr('title', 'Interim Translation Downloaded')
|
183 |
+
.attr('target','_blank')
|
184 |
+
.addClass('lingotek-interim-color dashicons dashicons-' + icon + ' dashicons-' + icon + '-lingotek');
|
185 |
+
$(td).prepend(request_link);
|
186 |
+
}
|
187 |
+
|
188 |
function updateGenericBulkLink(tr, data, key, action, title, text){
|
189 |
var row_actions = $(tr).find('.row-actions');
|
190 |
if($(row_actions).find('.lingotek-' + action).length === 0){
|
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.3.
|
6 |
Author: Lingotek and Frédéric Demarle
|
7 |
Author uri: http://lingotek.com
|
8 |
Description: Lingotek offers convenient cloud-based localization and translation.
|
@@ -16,7 +16,7 @@ if ( ! function_exists( 'add_action' ) ) {
|
|
16 |
exit();
|
17 |
}
|
18 |
|
19 |
-
define( 'LINGOTEK_VERSION', '1.3.
|
20 |
define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
|
21 |
define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
|
22 |
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.3.7
|
6 |
Author: Lingotek and Frédéric Demarle
|
7 |
Author uri: http://lingotek.com
|
8 |
Description: Lingotek offers convenient cloud-based localization and translation.
|
16 |
exit();
|
17 |
}
|
18 |
|
19 |
+
define( 'LINGOTEK_VERSION', '1.3.7' ); // plugin version (should match above meta).
|
20 |
define( 'LINGOTEK_MIN_PLL_VERSION', '1.8' );
|
21 |
define( 'LINGOTEK_BASENAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
|
22 |
define( 'LINGOTEK_PLUGIN_SLUG', 'lingotek-translation' );// plugin slug (should match above meta: Text Domain).
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.9
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -122,7 +122,11 @@ For more, visit the [Lingotek documentation site](https://lingotek.atlassian.net
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
-
= 1.3.
|
|
|
|
|
|
|
|
|
126 |
|
127 |
* Removed option to connect to Lingotek Sandbox environment
|
128 |
|
4 |
Tags: automation, bilingual, international, language, Lingotek, localization, multilanguage, multilingual, translate, translation
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 1.3.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
+
= 1.3.7 (2018-2-23) =
|
126 |
+
|
127 |
+
* Added ability to download translations at any point of the content's workflow
|
128 |
+
|
129 |
+
= 1.3.6 (2018-2-9) =
|
130 |
|
131 |
* Removed option to connect to Lingotek Sandbox environment
|
132 |
|