Changeset 3515
- Timestamp:
- 06/21/2016 09:32:38 AM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-code-import.php
r3507 r3515 88 88 } 89 89 90 parent::set_glotpress_for_plugin( $this->plugin, 'code' ); 90 $result = $this->set_glotpress_for_plugin( $this->plugin, 'code' ); 91 if ( is_wp_error( $result ) ) { 92 throw new Exception( $result->get_error_message() ); 93 } 91 94 92 95 $branch = ( 'trunk' === $tag ) ? 'dev' : 'stable'; 93 parent::import_pot_to_glotpress_project( $this->plugin, $branch, $pot_file );96 $this->import_pot_to_glotpress_project( $this->plugin, $branch, $pot_file ); 94 97 95 // @todo: Import translations only once. 98 // Import translations on initial import. 99 if ( 'created' === $result ) { 100 $this->import_translations_to_glotpress_project( $export_directory, $this->plugin, $branch ); 101 } 96 102 } 97 103 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-i18n-import.php
r3507 r3515 2 2 namespace WordPressdotorg\Plugin_Directory\CLI\I18N; 3 3 use WordPressdotorg\Plugin_Directory\Plugin_I18n; 4 use WordPressdotorg\Plugin_Directory\Tools\Filesystem; 4 5 use WP_Error; 5 6 … … 69 70 70 71 /** 71 * Import generated POT file to GlotPress 72 * Import generated POT file to GlotPress. 72 73 * 73 * @param string $project GP project slug to import to74 * @param string $branch GP project branch to import to (dev|stable)75 * @param string $file Path to POT file74 * @param string $project GP project slug to import to 75 * @param string $branch GP project branch to import to (dev|stable) 76 * @param string $file Path to POT file 76 77 * @param array $str_priorities GP string priorities 77 78 */ 78 function import_pot_to_glotpress_project( $project, $branch, $file, $str_priorities = array() ) {79 public function import_pot_to_glotpress_project( $project, $branch, $file, $str_priorities = array() ) { 79 80 global $wpdb; 80 81 … … 102 103 } 103 104 } 105 106 /** 107 * Import existing plugin translations to GlotPress. 108 * See translate/bin/translations/import-plugin-translations.php 109 * 110 * @param string $export_directory Relative path as provided by Dotorg_Plugins_Tracker. 111 * @param string $project GP project slug to import to 112 * @param string $branch GP project branch to import to (dev|stable) 113 */ 114 public function import_translations_to_glotpress_project( $export_directory, $project, $branch ) { 115 $files = Filesystem::list_files( $export_directory, true, '/\.po$/' ); 116 117 if ( empty( $files ) ) { 118 $files = Filesystem::list_files( $export_directory, true, '/\.mo$/' ); 119 } 120 121 foreach ( $files as $file ) { 122 $filename = basename( $file ); 123 if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).(po|mo)$/', $filename, $match ) ) { 124 continue; 125 } 126 127 list( , , $language, $ext ) = $match; 128 129 // Fix some locales. 130 switch ( $language ) { 131 case 'ga_IR' : 132 $language = 'ga'; 133 break; 134 case 'ca_ES' : 135 $language = 'ca'; 136 break; 137 case 'el_GR' : 138 $language = 'el'; 139 break; 140 case 'af_ZA' : 141 $language = 'af'; 142 break; 143 case 'zh_cn' : 144 case 'zh_ZH' : 145 $language = 'zh_CN'; 146 break; 147 case 'uk_UA' : 148 $language = 'uk'; 149 break; 150 case 'sq_AL' : 151 $language = 'sq'; 152 break; 153 case 'ga_IE' : 154 $language = 'ga'; 155 break; 156 case 'gu_IN' : 157 $language = 'gu'; 158 break; 159 case 'hy_AM' : 160 $language = 'hy'; 161 break; 162 case 'eo_EO' : 163 $language = 'eo'; 164 break; 165 case 'ar_AR' : 166 $language = 'ar'; 167 break; 168 case 'hr_HR' : 169 $language = 'hr'; 170 break; 171 case 'cs_CS' : 172 $language = 'cs_CZ'; 173 break; 174 case 'vi_VN' : 175 $language = 'vi'; 176 break; 177 case 'ja_JP' : 178 $language = 'ja'; 179 break; 180 case 'tr' : 181 $language = 'tr_TR'; 182 break; 183 case 'be_BY' : 184 case 'be' : 185 $language = 'bel'; 186 break; 187 } 188 189 $cmd = WPORGTRANSLATE_WPCLI . ' wporg-translate import-plugin-translations ' . escapeshellarg( "wp-plugins/{$project}/{$branch}" ) . ' ' . escapeshellarg( $language ) . ' ' . escapeshellarg( $file ) . ' --format=' . escapeshellarg( $ext ); 190 echo shell_exec( $cmd . ' 2>&1' ); 191 } 192 } 104 193 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-readme-import.php
r3507 r3515 39 39 */ 40 40 public function import_from_tag( $tag ) { 41 global $wpdb;42 43 41 $files = SVN::ls( self::PLUGIN_SVN_BASE . "/{$this->plugin}/{$tag}" ); 44 42 if ( ! $files ) { … … 151 149 } 152 150 153 parent::set_glotpress_for_plugin( $this->plugin, 'readme' ); 151 $result = $this->set_glotpress_for_plugin( $this->plugin, 'readme' ); 152 if ( is_wp_error( $result ) ) { 153 throw new Exception( $result->get_error_message() ); 154 } 154 155 155 156 $branch = ( 'trunk' === $tag ) ? 'dev' : 'stable'; 156 parent::import_pot_to_glotpress_project( $this->plugin, $branch, $pot_file, $str_priorities );157 $this->import_pot_to_glotpress_project( $this->plugin, $branch, $pot_file, $str_priorities ); 157 158 } 158 159 … … 166 167 * @return array 167 168 */ 168 function handle_translator_comment( $array, $key, $val ) {169 private function handle_translator_comment( $array, $key, $val ) { 169 170 $val = trim( preg_replace( '/[^a-z0-9]/i', ' ', $val ) ); // cleanup key names for display. 170 171
Note: See TracChangeset
for help on using the changeset viewer.