Changeset 6198
- Timestamp:
- 12/01/2017 10:50:11 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r6127 r6198 916 916 * @return array 917 917 */ 918 public function sync_all_translations_to_meta( $post_id, $min_translated = 60, $skip_pfx = array('en_') ) {918 public function sync_all_translations_to_meta( $post_id, $min_translated = 40, $skip_pfx = array('en_') ) { 919 919 920 920 $locales_to_sync = array(); 921 921 $post = get_post( $post_id ); 922 922 if ( $post ) { 923 $translations = Plugin_I18n:: find_all_translations_for_plugin( $post->post_name, 'stable-readme', $min_translated ); // at least $min_translated % translated923 $translations = Plugin_I18n::instance()->find_all_translations_for_plugin( $post->post_name, 'stable-readme', $min_translated ); // at least $min_translated % translated 924 924 if ( $translations ) { 925 925 // Eliminate translations that start with unwanted prefixes, so we don't waste space on near-duplicates like en_AU, en_CA etc. … … 952 952 public function sync_translation_to_meta( $post_id, $_locale ) { 953 953 global $locale; 954 954 955 $old_locale = $locale; 956 // Keep track of the original untranslated strings 957 $orig_title = get_the_title( $post_id ); 958 $orig_excerpt = get_the_excerpt( $post_id ); 959 $orig_content = get_post_field( 'post_content', $post_id ); 955 960 $locale = $_locale; 956 961 … … 958 963 // There is a bug here, in that no attempt is made to remove old meta values for translations that do not have new translations. 959 964 960 $the_title = Plugin_I18n::instance()->translate( 'title', get_the_title( $post_id ), [ 'post_id' => $post_id ] );961 if ( $the_title && $the_title != get_the_title( $post_id )) {965 $the_title = Plugin_I18n::instance()->translate( 'title', $orig_title, [ 'post_id' => $post_id ] ); 966 if ( $the_title && $the_title != $orig_title ) { 962 967 update_post_meta( $post_id, 'title_' . $locale, $the_title ); 963 968 } 964 969 965 $the_excerpt = $this->translate_post_excerpt( get_the_excerpt( $post_id ), $post_id );966 if ( $the_excerpt && $the_excerpt != get_the_excerpt( $post_id )) {970 $the_excerpt = $this->translate_post_excerpt( $orig_excerpt, $post_id ); 971 if ( $the_excerpt && $the_excerpt != $orig_excerpt ) { 967 972 update_post_meta( $post_id, 'excerpt_' . $locale, $the_excerpt ); 968 973 } … … 970 975 // Split up the content to translate it in sections. 971 976 $the_content = array(); 972 $sections = $this->split_post_content_into_pages( get_the_content( $post_id ));977 $sections = $this->split_post_content_into_pages( $orig_content ); 973 978 foreach ( $sections as $section => $section_content ) { 974 979 $translated_section = $this->translate_post_content( $section_content, $section, $post_id ); 975 980 if ( $translated_section && $translated_section != $section_content ) { 976 $the_content[] = $translated_section; 981 // ES expects the section delimiters to still be present 982 $the_content[ $section ] = "<!--section={$section}-->\n" . $translated_section; 977 983 } 978 984 } 979 if ( !empty( $the_content ) ) 985 986 if ( !empty( $the_content ) ) { 980 987 update_post_meta( $post_id, 'content_' . $locale, implode( $the_content ) ); 988 } 981 989 982 990 $locale = $old_locale;
Note: See TracChangeset
for help on using the changeset viewer.