Changeset 1248850
- Timestamp:
- 09/18/2015 10:02:37 PM (11 years ago)
- Location:
- lingotek-translation
- Files:
-
- 90 added
- 11 edited
-
tags/1.1.1 (added)
-
tags/1.1.1/admin (added)
-
tags/1.1.1/admin/actions.php (added)
-
tags/1.1.1/admin/admin.php (added)
-
tags/1.1.1/admin/content-table.php (added)
-
tags/1.1.1/admin/custom-fields-table.php (added)
-
tags/1.1.1/admin/filters-columns.php (added)
-
tags/1.1.1/admin/filters-media.php (added)
-
tags/1.1.1/admin/filters-post.php (added)
-
tags/1.1.1/admin/filters-term.php (added)
-
tags/1.1.1/admin/manage (added)
-
tags/1.1.1/admin/manage/view-content.php (added)
-
tags/1.1.1/admin/manage/view-custom-fields.php (added)
-
tags/1.1.1/admin/manage/view-edit-profile.php (added)
-
tags/1.1.1/admin/manage/view-profiles.php (added)
-
tags/1.1.1/admin/manage/view-string-groups.php (added)
-
tags/1.1.1/admin/manage/view-strings.php (added)
-
tags/1.1.1/admin/post-actions.php (added)
-
tags/1.1.1/admin/profiles-table.php (added)
-
tags/1.1.1/admin/settings (added)
-
tags/1.1.1/admin/settings.php (added)
-
tags/1.1.1/admin/settings/connect-account.php (added)
-
tags/1.1.1/admin/settings/view-account.php (added)
-
tags/1.1.1/admin/settings/view-defaults.php (added)
-
tags/1.1.1/admin/settings/view-preferences.php (added)
-
tags/1.1.1/admin/settings/view-utilities.php (added)
-
tags/1.1.1/admin/string-actions.php (added)
-
tags/1.1.1/admin/strings-table.php (added)
-
tags/1.1.1/admin/table-string.php (added)
-
tags/1.1.1/admin/term-actions.php (added)
-
tags/1.1.1/admin/tutorial (added)
-
tags/1.1.1/admin/tutorial/content.php (added)
-
tags/1.1.1/admin/tutorial/credits.php (added)
-
tags/1.1.1/admin/tutorial/faq.php (added)
-
tags/1.1.1/admin/tutorial/features.php (added)
-
tags/1.1.1/admin/tutorial/img (added)
-
tags/1.1.1/admin/tutorial/img/add-languages.png (added)
-
tags/1.1.1/admin/tutorial/img/add-page.png (added)
-
tags/1.1.1/admin/tutorial/img/add-page2.png (added)
-
tags/1.1.1/admin/tutorial/img/automatic-translation.gif (added)
-
tags/1.1.1/admin/tutorial/img/automatic-translation.png (added)
-
tags/1.1.1/admin/tutorial/img/check-status.png (added)
-
tags/1.1.1/admin/tutorial/img/content-types.png (added)
-
tags/1.1.1/admin/tutorial/img/dashboard.png (added)
-
tags/1.1.1/admin/tutorial/img/polylang-compatible.png (added)
-
tags/1.1.1/admin/tutorial/img/pro-translation.png (added)
-
tags/1.1.1/admin/tutorial/img/professional-translation.png (added)
-
tags/1.1.1/admin/tutorial/img/ready-to-upload.png (added)
-
tags/1.1.1/admin/tutorial/img/request-translations.png (added)
-
tags/1.1.1/admin/tutorial/img/translation-profiles.png (added)
-
tags/1.1.1/admin/tutorial/img/translation-services.png (added)
-
tags/1.1.1/admin/tutorial/img/translations-downloaded.png (added)
-
tags/1.1.1/admin/tutorial/img/translations-ready-for-download.png (added)
-
tags/1.1.1/admin/tutorial/img/translations-underway.png (added)
-
tags/1.1.1/admin/tutorial/img/workbench-full.png (added)
-
tags/1.1.1/admin/tutorial/img/workbench.png (added)
-
tags/1.1.1/admin/utilities.php (added)
-
tags/1.1.1/admin/view-dashboard.php (added)
-
tags/1.1.1/admin/view-manage.php (added)
-
tags/1.1.1/admin/view-network.php (added)
-
tags/1.1.1/admin/view-tutorial.php (added)
-
tags/1.1.1/admin/wp-import.php (added)
-
tags/1.1.1/css (added)
-
tags/1.1.1/css/admin.css (added)
-
tags/1.1.1/img (added)
-
tags/1.1.1/img/lingotek-chevrons-blue.png (added)
-
tags/1.1.1/img/lingotek-icon.png (added)
-
tags/1.1.1/img/lingotek-white.png (added)
-
tags/1.1.1/include (added)
-
tags/1.1.1/include/api.php (added)
-
tags/1.1.1/include/callback.php (added)
-
tags/1.1.1/include/dashboard.php (added)
-
tags/1.1.1/include/group-post.php (added)
-
tags/1.1.1/include/group-string.php (added)
-
tags/1.1.1/include/group-term.php (added)
-
tags/1.1.1/include/group.php (added)
-
tags/1.1.1/include/http.php (added)
-
tags/1.1.1/include/model.php (added)
-
tags/1.1.1/include/plugins-compat.php (added)
-
tags/1.1.1/include/pointer.php (added)
-
tags/1.1.1/js (added)
-
tags/1.1.1/js/defaults.js (added)
-
tags/1.1.1/js/progress.js (added)
-
tags/1.1.1/js/updater.js (added)
-
tags/1.1.1/languages (added)
-
tags/1.1.1/languages/wp-lingotek-fr_FR.mo (added)
-
tags/1.1.1/languages/wp-lingotek-fr_FR.po (added)
-
tags/1.1.1/lingotek.php (added)
-
tags/1.1.1/readme.txt (added)
-
tags/1.1.1/uninstall.php (added)
-
trunk/admin/actions.php (modified) (3 diffs)
-
trunk/admin/admin.php (modified) (1 diff)
-
trunk/admin/filters-columns.php (modified) (5 diffs)
-
trunk/css/admin.css (modified) (1 diff)
-
trunk/include/api.php (modified) (1 diff)
-
trunk/include/group-post.php (modified) (6 diffs)
-
trunk/include/group.php (modified) (4 diffs)
-
trunk/include/model.php (modified) (7 diffs)
-
trunk/js/defaults.js (modified) (1 diff)
-
trunk/lingotek.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lingotek-translation/trunk/admin/actions.php
r1243686 r1248850 96 96 ), 97 97 98 'error' => array( 99 'title' => __('There was an error contacting Lingotek', 'wp-lingotek'), 100 'icon' => 'warning' 101 ), 98 // Removed error reporting for release 1.1.2 99 // 'error' => array( 100 // 'title' => __('There was an error contacting Lingotek', 'wp-lingotek'), 101 // 'icon' => 'warning' 102 // ), 102 103 ); 103 104 … … 187 188 } 188 189 189 /* 190 * outputs an API error icon 191 * 192 * @since 0.2 193 * 194 * @param string $name 195 * @param string $additional parameters to add (js, target) 196 */ 197 public static function display_error_icon($name, $api_error, $additional = '') { 198 return sprintf('<span class="lingotek-error dashicons dashicons-%s" title="%s"></span>', 199 self::$icons[$name]['icon'], self::$icons[$name]['title'] . "\n" . $api_error, $additional); 200 } 190 // Removed error reporting for release 1.1.2 191 // /* 192 // * outputs an API error icon 193 // * 194 // * @since 0.2 195 // * 196 // * @param string $name 197 // * @param string $additional parameters to add (js, target) 198 // */ 199 // public static function display_error_icon($name, $api_error, $additional = '') { 200 // return sprintf('<span class="lingotek-error dashicons dashicons-%s" title="%s"></span>', 201 // self::$icons[$name]['icon'], self::$icons[$name]['title'] . "\n" . $api_error, $additional); 202 // } 201 203 202 204 /* … … 486 488 check_ajax_referer('lingotek_progress', '_lingotek_nonce'); 487 489 if ($document = $this->lgtm->get_group($this->type, $_POST['id'])) { 488 $document->disassociate(); 490 $document->disassociate(); 489 491 } 490 492 die(); -
lingotek-translation/trunk/admin/admin.php
r1243686 r1248850 96 96 foreach ($content_metadata as $group => $status) { 97 97 $language_obj = $pllm->get_language($source_language); 98 $target_lang_obj = $pllm->get_language($language); 98 99 $profile = Lingotek_Model::get_profile($taxonomy, $language_obj, $group); 99 100 if ($profile['profile'] != 'disabled' && $status['source'] != false) { 100 101 if (!isset($status[$language])) { 101 102 $content_metadata[$group][$language]['status'] = "none"; 102 if ($document->is_disabled_target($pllm->get_language($source_language), $pllm->get_language($language)) ) {103 if ($document->is_disabled_target($pllm->get_language($source_language), $pllm->get_language($language)) || (isset($document->desc_array[$target_lang_obj->slug]) && !isset($document->source))) { 103 104 $content_metadata[$group][$language]['status'] = 'disabled'; 104 105 } -
lingotek-translation/trunk/admin/filters-columns.php
r1243686 r1248850 96 96 97 97 $document = $this->lgtm->get_group($type, $object_id); 98 if (isset($document->source)) { 99 $source_language = $type == 'post' ? $this->model->get_post_language($document->source) : $this->model->get_term_language($document->source); 100 } 101 else { 102 $source_language = $lang; 103 } 98 104 99 105 // FIXME not very clean … … 101 107 102 108 $profile = Lingotek_Model::get_profile($this->content_type, $language, $object_id); 109 $source_profile = Lingotek_Model::get_profile($this->content_type, $lang, $id); 103 110 $disabled = 'disabled' == $profile['profile']; 104 111 … … 112 119 113 120 // translation disabled 114 elseif (isset($document->source) && $document->is_disabled_target($ lang, $language) && !isset($document->translations[$language->locale])) {121 elseif (isset($document->source) && $document->is_disabled_target($source_language, $language) && !isset($document->translations[$language->locale])) { 115 122 return 'post' == $type ? parent::post_column($column, $object_id) : parent::term_column('', $column, $object_id); 116 123 } … … 165 172 public function post_column($column, $post_id) { 166 173 $this->content_type = get_post_type($post_id); 167 174 168 175 echo $this->_column('post', $column, $post_id); 169 176 177 // Removed error reporting for release 1.1.2 170 178 // checking for api errors 171 $column_language_only = substr($column, 0, 11); 172 $group = $this->lgtm->get_group('post', $post_id); 173 174 if ($group) { 175 $source = $group->desc_array['lingotek']['source']; 176 // remove the remnants of previous API errors if there aren't any current errors 177 if (isset($group->desc_array['lingotek']['api_errors'])) { 178 $api_errors = $group->desc_array['lingotek']['api_errors']; 179 if (empty($api_errors)) { 180 unset($group->desc_array['lingotek']['api_errors']); 181 } 182 } 183 if ($column_language_only == $this->get_first_language_column() && $post_id === $source && isset($group->desc_array['lingotek']['api_errors'])) { 184 $error = $this->retrieve_api_error($group); 185 echo Lingotek_Actions::display_error_icon('error', $error); 186 } 187 } 179 // $column_language_only = substr($column, 0, 11); 180 // $group = $this->lgtm->get_group('post', $post_id); 181 182 // if ($group) { 183 // $source = $group->desc_array['lingotek']['source']; 184 // // remove the remnants of previous API errors if there aren't any current errors 185 // if (isset($group->desc_array['lingotek']['api_errors'])) { 186 // $api_errors = $group->desc_array['lingotek']['api_errors']; 187 // if (empty($api_errors)) { 188 // unset($group->desc_array['lingotek']['api_errors']); 189 // $group->save(); 190 // } 191 // } 192 // if ($column_language_only == $this->get_first_language_column() && $post_id === $source && isset($group->desc_array['lingotek']['api_errors'])) { 193 // $error = $this->retrieve_api_error($group); 194 // echo Lingotek_Actions::display_error_icon('error', $error); 195 // } 196 // } 188 197 } 189 198 … … 208 217 } 209 218 210 211 / *212 * collects and returns all API errors in the group object213 *214 * @since 1.1215 *216 * @param string $group217 */218 protected function retrieve_api_error($group) {219 $api_error = "\n";220 221 if (isset($group->desc_array['lingotek']['api_errors']['source_status'])){222 $source_status = $group->desc_array['lingotek']['api_errors']['source_status'];223 $api_error = $api_error . $source_status . "\n";224 }225 if (isset($group->desc_array['lingotek']['api_errors']['translations_status'])){226 $translations_status = $group->desc_array['lingotek']['api_errors']['translations_status'];227 $api_error = $api_error . $translations_status . "\n";228 }229 if (isset($group->desc_array['lingotek']['api_errors']['request_translation'])){230 $request_translation = $group->desc_array['lingotek']['api_errors']['request_translation'];231 $api_error = $api_error . $request_translation . "\n";232 }233 if (isset($group->desc_array['lingotek']['api_errors']['_request_translations'])) {234 $request_translations = $group->desc_array['lingotek']['api_errors']['_request_translations'];235 foreach ($request_translations as $lang => $error) {236 $api_error = $api_error . $error . "\n";237 }238 }239 if (isset($group->desc_array['lingotek']['api_errors']['create_translation'])) {240 $create_translation = $group->desc_array['lingotek']['api_errors']['create_translation'];241 foreach ($create_translation as $locale => $error) {242 $api_error = $api_error . $error . "\n";243 }244 }245 if (isset($group->desc_array['lingotek']['api_errors']['disassociate'])) {246 $disassociate = $group->desc_array['lingotek']['api_errors']['disassociate'];247 $api_error = $api_error . $disassociate . "\n";248 }249 if (isset($group->desc_array['lingotek']['api_errors']['patch'])) {250 $patch = $group->desc_array['lingotek']['api_errors']['patch'];251 $api_error = $api_error . $patch . "\n";252 }253 if (isset($group->desc_array['lingotek']['api_errors']['upload'])) {254 $upload = $group->desc_array['lingotek']['api_errors']['upload'];255 $api_error = $api_error . $upload . "\n";256 }257 return $api_error;258 }219 // Removed error reporting for release 1.1.2 220 // /* 221 // * collects and returns all API errors in the group object 222 // * 223 // * @since 1.1 224 // * 225 // * @param string $group 226 // */ 227 // protected function retrieve_api_error($group) { 228 // $api_error = "\n"; 229 230 // if (isset($group->desc_array['lingotek']['api_errors']['source_status'])){ 231 // $source_status = $group->desc_array['lingotek']['api_errors']['source_status']; 232 // $api_error = $api_error . $source_status . "\n"; 233 // } 234 // if (isset($group->desc_array['lingotek']['api_errors']['translations_status'])){ 235 // $translations_status = $group->desc_array['lingotek']['api_errors']['translations_status']; 236 // $api_error = $api_error . $translations_status . "\n"; 237 // } 238 // if (isset($group->desc_array['lingotek']['api_errors']['request_translation'])){ 239 // $request_translation = $group->desc_array['lingotek']['api_errors']['request_translation']; 240 // $api_error = $api_error . $request_translation . "\n"; 241 // } 242 // if (isset($group->desc_array['lingotek']['api_errors']['_request_translations'])) { 243 // $request_translations = $group->desc_array['lingotek']['api_errors']['_request_translations']; 244 // foreach ($request_translations as $lang => $error) { 245 // $api_error = $api_error . $error . "\n"; 246 // } 247 // } 248 // if (isset($group->desc_array['lingotek']['api_errors']['create_translation'])) { 249 // $create_translation = $group->desc_array['lingotek']['api_errors']['create_translation']; 250 // foreach ($create_translation as $locale => $error) { 251 // $api_error = $api_error . $error . "\n"; 252 // } 253 // } 254 // if (isset($group->desc_array['lingotek']['api_errors']['disassociate'])) { 255 // $disassociate = $group->desc_array['lingotek']['api_errors']['disassociate']; 256 // $api_error = $api_error . $disassociate . "\n"; 257 // } 258 // if (isset($group->desc_array['lingotek']['api_errors']['patch'])) { 259 // $patch = $group->desc_array['lingotek']['api_errors']['patch']; 260 // $api_error = $api_error . $patch . "\n"; 261 // } 262 // if (isset($group->desc_array['lingotek']['api_errors']['upload'])) { 263 // $upload = $group->desc_array['lingotek']['api_errors']['upload']; 264 // $api_error = $api_error . $upload . "\n"; 265 // } 266 // return $api_error; 267 // } 259 268 } -
lingotek-translation/trunk/css/admin.css
r1243686 r1248850 88 88 89 89 .lingotek-error { 90 color: # FF0000;90 color: #999999; 91 91 } 92 92 -
lingotek-translation/trunk/include/api.php
r1243686 r1248850 188 188 } 189 189 } 190 else { 191 if (wp_remote_retrieve_response_code($response) != 404) { 192 return false; 193 } 194 } 190 // Removed error reporting for release 1.1.2 191 // else { 192 // if (empty(wp_remote_retrieve_response_code($response))) { 193 // return false; 194 // } 195 // } 195 196 196 197 return empty($translations) ? array() : $translations; -
lingotek-translation/trunk/include/group-post.php
r1243686 r1248850 56 56 ); 57 57 58 // if the user hasn't visited the custom fields tab, and hasn't saved actions for custom 59 // fields, and uploaded a post, check the wpml file for settings 58 // if the user hasn't visited the custom fields tab, and hasn't saved actions for custom 59 // fields, and uploaded a post, check the wpml file for settings 60 60 if ($post_ID) { 61 61 self::get_updated_meta_values($post_ID); … … 108 108 static public function get_custom_fields_from_wp_postmeta($post_ID = NULL) { 109 109 $custom_fields = get_option('lingotek_custom_fields', array()); 110 $meta_black_list = array('_encloseme', '_edit_last', '_edit_lock', '_wp_trash_meta_status', '_wp_trash_meta_time'); 110 $meta_black_list = array('_encloseme', '_edit_last', '_edit_lock', '_wp_trash_meta_status', '_wp_trash_meta_time'); 111 111 $arr = array(); 112 112 $keys = array(); … … 154 154 155 155 /* 156 * updates meta (custom) fields values in the lingotek_custom_fields option 156 * updates meta (custom) fields values in the lingotek_custom_fields option 157 157 * 158 158 * @since 0.2 … … 198 198 199 199 /* 200 * returns cached meta (custom) fields values in the lingotek_custom_fields option 200 * returns cached meta (custom) fields values in the lingotek_custom_fields option 201 201 * 202 202 * @since 0.2 … … 255 255 } 256 256 } 257 257 258 258 return json_encode($arr); 259 259 } … … 294 294 295 295 if (false === ($translation = $client->get_translation($this->document_id, $locale))) { 296 // Error reporting here causes problems. FIXME296 // Error reporting removed for release 1.1.2 297 297 // $this->desc_array['lingotek']['api_errors']['create_translation'][$locale] = __('Error downloading ', 'wp-lingotek') . $locale . __(' translation for post ', 'wp-lingotek') . $this->source; 298 298 // $this->save(); 299 299 return; 300 300 } 301 // else { 302 // unset($this->desc_array['lingotek']['api_errors']['create_translation'][$locale]); 303 // $this->save(); 304 // } 301 //else { 302 // unset($this->desc_array['lingotek']['api_errors']['create_translation'][$locale]); 303 // if (empty($this->desc_array['lingotek']['api_errors']['create_translation'])) { 304 // unset($this->desc_array['lingotek']['api_errors']['create_translation']); 305 // } 306 // $this->save(); 307 //} 305 308 306 309 self::$creating_translation = true; -
lingotek-translation/trunk/include/group.php
r1243686 r1248850 140 140 $this->status = 'importing'; 141 141 $this->translations = array_fill_keys(array_keys($this->translations), 'pending'); 142 unset($this->desc_array['lingotek']['api_errors']['patch']); 142 // Removed error reporting for release 1.1.2 143 // unset($this->desc_array['lingotek']['api_errors']['patch']); 144 // $this->save(); 145 // } 146 // else { 147 // $this->desc_array['lingotek']['api_errors']['patch'] = __('Error uploading updated post ', 'wp-lingotek') . $this->source; 148 $this->save(); 149 } 150 } 151 152 /* 153 * checks the status of source document 154 * 155 * @since 0.2 156 */ 157 public function source_status() { 158 $client = new Lingotek_API(); 159 160 if ('importing' == $this->status && $client->document_exists($this->document_id)) { 161 $this->status = 'current'; 143 162 $this->save(); 144 163 } 145 else { 146 $this->desc_array['lingotek']['api_errors']['patch'] = __('Error uploading updated post ', 'wp-lingotek') . $this->source; 147 $this->save(); 148 } 149 } 150 151 /* 152 * checks the status of source document 153 * 154 * @since 0.2 155 */ 156 public function source_status() { 157 $client = new Lingotek_API(); 158 159 if ($client->document_exists($this->document_id)) { 160 unset($this->desc_array['lingotek']['api_errors']['source_status']); 161 if ('importing' == $this->status) { 162 $this->status = 'current'; 163 } 164 } 165 // note api errors 166 else { 167 $this->desc_array['lingotek']['api_errors']['source_status'] = __('Error updating translation status of post ', 'wp-lingotek') . $this->source; 168 } 169 170 $this->save(); 164 165 // Removed error reporting for release 1.1.2 166 // $response = $client->document_exists($this->document_id); 167 168 // if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) { 169 // unset($this->desc_array['lingotek']['api_errors']['source_status']); 170 // if ('importing' == $this->status) { 171 // $this->status = 'current'; 172 // } 173 // } 174 // elseif (400 == wp_remote_retrieve_response_code($response) || empty(wp_remote_retrieve_response_code($response))) { 175 // $this->desc_array['lingotek']['api_errors']['source_status'] = __('Error updating source status of post ', 'wp-lingotek') . $this->source; 176 // } 177 178 // $this->save(); 171 179 } 172 180 … … 195 203 196 204 if (!$this->is_disabled_target($language) && empty($this->translations[$language->locale])) { 197 if ($client->request_translation($this->document_id, $language->locale, $args)) { 198 $this->status = 'current'; 199 $this->translations[$language->locale] = 'pending'; 200 unset($this->desc_array['lingotek']['api_errors']['request_translation']); 201 } 202 else { 203 $this->desc_array['lingotek']['api_errors']['request_translation'] = __('Error requesting translations for post ', 'wp-lingotek') . $this->source; 204 } 205 205 $client->request_translation($this->document_id, $language->locale, $args); 206 $this->status = 'current'; 207 $this->translations[$language->locale] = 'pending'; 208 // Removed error reporting for release 1.1.2 209 // if ($client->request_translation($this->document_id, $language->locale, $args)) { 210 // $this->status = 'current'; 211 // $this->translations[$language->locale] = 'pending'; 212 // unset($this->desc_array['lingotek']['api_errors']['request_translation']); 213 // unset($this->desc_array['lingotek']['api_errors']['_request_translations']); 214 // } 215 // else { 216 // $this->desc_array['lingotek']['api_errors']['request_translation'] = __('Error requesting translation for ' . $language->name . ' for post ', 'wp-lingotek') . $this->source; 217 // } 218 206 219 $this->save(); 207 220 } … … 222 235 $workflow = Lingotek_Model::get_profile_option('workflow_id', $this->type, $source_language, $lang, $this->source); 223 236 $args = $workflow ? array('workflow_id' => $workflow) : array(); 224 if ($client->request_translation($this->document_id, $lang->lingotek_locale, $args)) { 225 $this->status = 'current'; 226 $this->translations[$lang->locale] = 'pending'; 227 unset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name]); 228 } 229 else { 230 $this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name] = __('Error requesting translation for ', 'wp-lingotek') . $lang->name . __(' for post ', 'wp-lingotek') . $this->source; 231 } 237 $client->request_translation($this->document_id, $lang->lingotek_locale, $args); 238 $this->status = 'current'; 239 $this->translations[$lang->locale] = 'pending'; 240 // Removed error reporting for release 1.1.2 241 // if ($client->request_translation($this->document_id, $lang->lingotek_locale, $args)) { 242 // $this->status = 'current'; 243 // $this->translations[$lang->locale] = 'pending'; 244 // unset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name]); 245 // unset($this->desc_array['lingotek']['api_errors']['request_translation']); 246 // if (empty($this->desc_array['lingotek']['api_errors']['_request_translations'])) { 247 // unset($this->desc_array['lingotek']['api_errors']['_request_translations']); 248 // } 249 // } 250 // else { 251 // if (!isset($this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name])) { 252 // $this->desc_array['lingotek']['api_errors']['_request_translations'][$lang->name] = __('Error requesting translation for ', 'wp-lingotek') . $lang->name . __(' for post ', 'wp-lingotek') . $this->source; 253 // } 254 // } 232 255 } 233 256 } … … 244 267 $client = new Lingotek_API(); 245 268 $translations = $client->get_translations_status($this->document_id); // key are Lingotek locales 246 if ($translations !== false) { 247 foreach($this->translations as $locale => $status) { 248 $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale; 249 if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale]) 250 $this->translations[$locale] = 'ready'; 251 } 252 unset($this->desc_array['lingotek']['api_errors']['translations_status']); 253 $this->save(); 254 } 255 // take note of api errors 256 else { 257 $this->desc_array['lingotek']['api_errors']['translations_status'] = __('Error checking translations status of post ', 'wp-lingotek') . $this->source; 258 $this->save(); 259 } 269 foreach($this->translations as $locale => $status) { 270 $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale; 271 if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale]) 272 $this->translations[$locale] = 'ready'; 273 // Removed error reporting for release 1.1.2 274 // if ($translations !== false) { 275 // foreach($this->translations as $locale => $status) { 276 // $lingotek_locale = $this->pllm->get_language($locale)->lingotek_locale; 277 // if ('current' != $status && isset($translations[$lingotek_locale]) && 100 == $translations[$lingotek_locale]) 278 // $this->translations[$locale] = 'ready'; 279 // } 280 // unset($this->desc_array['lingotek']['api_errors']['translations_status']); 281 // $this->save(); 282 // } 283 // // take note of api errors 284 // else { 285 // $this->desc_array['lingotek']['api_errors']['translations_status'] = __('Error checking translations status of post ', 'wp-lingotek') . $this->source; 286 // $this->save(); 287 } 288 $this->save(); 260 289 } 261 290 -
lingotek-translation/trunk/include/model.php
r1243686 r1248850 9 9 class Lingotek_Model { 10 10 public $pllm; // Polylang model 11 static public $copying_post; 12 static public $copying_term; 11 13 12 14 /* … … 210 212 */ 211 213 public function copy_post($post, $target) { 214 self::$copying_post = true; 212 215 $document = $this->get_group('post', $post->ID); 213 216 $prefs = self::get_prefs(); … … 226 229 $document->desc_array[$target] = $new_post_id; 227 230 $document->save(); 228 return $new_post_id; 229 } 230 else { 231 return false; 232 } 233 } 234 else { 235 return false; 236 } 231 } 232 } 233 self::$copying_post = false; 237 234 } 238 235 239 236 public function copy_term($term, $target, $taxonomy) { 237 self::$copying_term = true; 240 238 $document = $this->get_group('term', $term->term_id); 241 239 $cp_lang = $this->pllm->get_language($target); … … 254 252 $document->save(); 255 253 } 254 self::$copying_term = false; 256 255 } 257 256 … … 298 297 } 299 298 300 elseif (!Lingotek_Group::$creating_translation ) {299 elseif (!Lingotek_Group::$creating_translation && !self::$copying_post) { 301 300 $document_id = $client->upload_document($params); 302 301 303 302 if ($document_id) { 304 303 Lingotek_Group_Post::create($post->ID , $language, $document_id); 305 $group = $this->get_group('post', $post_id); 306 unset($group->desc_array['lingotek']['api_errors']['upload']); 307 $group->save(); 308 } 309 else { 310 $group = $this->get_group('post', $post_id); 311 $group->desc_array['lingotek']['api_errors']['upload'] = __('Error uploading post ', 'wp-lingotek') . $group->source; 312 $group->save(); 313 } 314 } 315 316 // If a translation profile has targets set to copy then copy them 317 $targets_to_copy = $this->targets_to_be_copied($profile); 318 if (!empty($targets_to_copy)) { 319 foreach ($targets_to_copy as $target) { 320 $this->copy_post($post, $target); 321 } 304 305 // If a translation profile has targets set to copy then copy them 306 $targets_to_copy = $this->targets_to_be_copied($profile); 307 if (!empty($targets_to_copy)) { 308 foreach ($targets_to_copy as $target) { 309 $this->copy_post($post, $target); 310 } 311 } 312 // Error reporting commented out for release 1.1.2 313 // $group = $this->get_group('post', $post_id); 314 // unset($group->desc_array['lingotek']['api_errors']['upload']); 315 // $group->save(); 316 } 317 // else { 318 // $group = $this->get_group('post', $post_id); 319 // $group->desc_array['lingotek']['api_errors']['upload'] = __('Error uploading post ', 'wp-lingotek') . $group->source; 320 // $group->save(); 321 // } 322 322 } 323 323 } … … 364 364 } 365 365 366 elseif (!Lingotek_Group::$creating_translation ) {366 elseif (!Lingotek_Group::$creating_translation && !self::$copying_term) { 367 367 $document_id = $client->upload_document($params); 368 368 369 369 if ($document_id) { 370 370 Lingotek_Group_Term::create($term_id, $taxonomy , $language, $document_id); 371 } 372 }373 374 // If a translation profile has targets set to copy then copy them375 $targets_to_copy = $this->targets_to_be_copied($profile);376 if (!empty($targets_to_copy)) {377 foreach ($targets_to_copy as $target) {378 $this->copy_term($term, $target, $taxonomy);371 372 // If a translation profile has targets set to copy then copy them 373 $targets_to_copy = $this->targets_to_be_copied($profile); 374 if (!empty($targets_to_copy)) { 375 foreach ($targets_to_copy as $target) { 376 $this->copy_term($term, $target, $taxonomy); 377 } 378 } 379 379 } 380 380 } … … 473 473 474 474 return !empty($language) && (empty($document) || 475 ( 1 == count($this->pllm->get_translations($type, $object_id)) && empty($document->source)) || // specific for terms as document is never empty475 (empty($document->translations) && empty($document->source)) || // specific for terms as document is never empty 476 476 (isset($document) && 'edited' == $document->status && $document->source == $object_id)); 477 477 } -
lingotek-translation/trunk/js/defaults.js
r1243686 r1248850 18 18 } 19 19 20 21 20 jQuery(document).ready(function($) { 22 if ($('#lingotek_profile_meta').val() == 'default') { 21 function init_profiles() { 22 var pl_choice = $('#post_lang_choice').val(); 23 var content_profiles = $('#lingotek-language-profiles').text(); 24 var content_json = $.parseJSON(content_profiles); 25 var profile_name = content_json[pl_choice] ? content_json[pl_choice] : content_json.defaults.content_default; 26 $('#lingotek_profile_meta option:first').text(content_json.defaults.title + ' (' + profile_name + ')'); 27 } 28 if ($('#lingotek_profile_meta').val() == 'default') { 23 29 $('#post_lang_choice').change(function(){ 24 var pl_choice = $('#post_lang_choice').val(); 25 var content_profiles = $('#lingotek-language-profiles').text(); 26 var content_json = $.parseJSON(content_profiles); 27 var profile_name = content_json[pl_choice] ? content_json[pl_choice] : content_json.defaults.content_default; 28 29 $('#lingotek_profile_meta option:first').text(content_json.defaults.title + ' (' + profile_name + ')'); 30 }).change(); 30 init_profiles(); 31 }); 32 init_profiles(); 31 33 } 32 34 }); -
lingotek-translation/trunk/lingotek.php
r1243686 r1248850 3 3 Plugin name: Lingotek Translation 4 4 Plugin URI: http://lingotek.com/wordpress#utm_source=wpadmin&utm_medium=plugin&utm_campaign=wplingotektranslationplugin 5 Version: 1.1. 15 Version: 1.1.2 6 6 Author: Lingotek and Frédéric Demarle 7 7 Author uri: http://lingotek.com … … 16 16 exit(); 17 17 18 define('LINGOTEK_VERSION', '1.1. 1'); // plugin version (should match above meta)18 define('LINGOTEK_VERSION', '1.1.2'); // plugin version (should match above meta) 19 19 define('LINGOTEK_MIN_PLL_VERSION', '1.7.4.2'); 20 20 define('LINGOTEK_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP -
lingotek-translation/trunk/readme.txt
r1243686 r1248850 5 5 Requires at least: 3.8 6 6 Tested up to: 4.3 7 Stable tag: 1.1. 17 Stable tag: 1.1.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 119 119 == Changelog == 120 120 121 = 1.1.2 (2015-09-18) = 122 123 * Fix for copy feature 124 * Fix for content status displays 125 * Other minor fixes 126 121 127 = 1.1.1 (2015-09-11) = 122 128
Note: See TracChangeset
for help on using the changeset viewer.