$basket_item ) { foreach ( $basket_item['to_langs'] as $language_code => $action ) { if ( is_numeric( $translators[ $language_code ] ) ) { $strings_local[ $language_code ][] = $basket_item_id; } else { $strings_remote[ $language_code ][] = $basket_item_id; } } } if ( $strings_remote ) { foreach ( $strings_remote as $target => $string_ids ) { $basket = new WPML_Translation_Basket( $wpdb ); $st_tp_job = new WPML_TP_String_Job( $wpdb, $basket, $wpml_translation_job_factory ); $result = $st_tp_job->send_strings_to_translation_service( $string_ids, $target, $translators[ $target ] ); if ( isset( $result['errors'] ) && count( $result['errors'] ) ) { foreach ( $result['errors'] as $error ) { $error_message = array( 'type' => 'error', 'text' => $error, ); $iclTranslationManagement->add_message( $error_message ); } } if ( ! $result ) { foreach ( $string_ids as $string_id ) { $default_string_language = $basket->get_source_language(); $string = icl_get_string_by_id( $string_id, $default_string_language ); $message = array( 'type' => 'error', 'text' => sprintf( __( 'String "%s" has not been sent.', 'wpml-translation-management' ), $string ), ); $iclTranslationManagement->add_message( $message ); } break; } } } $batch_name = isset( $batch_options['basket_name'] ) ? $batch_options['basket_name'] : null; foreach ( $strings_local as $target => $string_ids ) { self::translation_send_strings_local( $string_ids, $target, $translators[ $target ], $batch_name ); } } } public static function get_string_status_labels() { return array( ICL_TM_COMPLETE => __( 'Translation complete', 'wpml-translation-management' ), ICL_STRING_TRANSLATION_PARTIAL => __( 'Partial translation', 'wpml-translation-management' ), ICL_TM_NEEDS_UPDATE => __( 'Translation needs update', 'wpml-translation-management' ), ICL_TM_NOT_TRANSLATED => __( 'Not translated', 'wpml-translation-management' ), ICL_TM_WAITING_FOR_TRANSLATOR => __( 'Waiting for translator / In progress', 'wpml-translation-management' ), ICL_TM_IN_BASKET => __( 'Strings in the basket', 'wpml-translation-management' ), ); } public static function get_string_status_label( $status ) { $string_translation_states_enumeration = self::get_string_status_labels(); if ( isset( $string_translation_states_enumeration[ $status ] ) ) { return $string_translation_states_enumeration[ $status ]; } return false; } public static function translation_send_strings_local( $string_ids, $target, $translator_id = null, $basket_name = null ) { $batch_id = TranslationProxy_Batch::update_translation_batch( $basket_name ); foreach ( $string_ids as $string_id ) { $string_translation_id = icl_add_string_translation( $string_id, $target, null, ICL_TM_WAITING_FOR_TRANSLATOR, $translator_id, 'local', $batch_id ); if ( $string_translation_id ) { $job = new WPML_String_Translation_Job( $string_translation_id ); do_action( 'wpml_tm_local_string_sent', $job ); } } return 1; } public static function display_string_menu( $lang_filter ) { global $sitepress; $target_status = array(); $target_rate = array(); $lang_status = $sitepress->get_setting( 'icl_lang_status' ); $strings_target_languages = $sitepress->get_active_languages(); if ( $lang_status ) { foreach ( $lang_status as $lang ) { if ( $lang['from'] == $sitepress->get_current_language() ) { $target_status[ $lang['to'] ] = $lang['have_translators']; $target_rate[ $lang['to'] ] = $lang['max_rate']; } } } ?>
get_var( $wpdb->prepare( " SELECT translation_service FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %d AND translation_service > 0 AND status IN (%d, %d) LIMIT 1 ", $string_id, ICL_TM_WAITING_FOR_TRANSLATOR, ICL_TM_IN_PROGRESS ) ); if ( $translation_service ) { $text = $text . " : " . sprintf( __( 'One or more strings sent to %s', 'wpml-translation-management' ), TranslationProxy::get_service_name( $translation_service ) ); } } return $text; } }