コード例 #1
0
 function action_on_translation_set($translation_set)
 {
     $project = GP::$project->get($translation_set->project_id);
     $locale = GP_Locales::by_slug($translation_set->locale);
     foreach (GP::$translation->for_translation($project, $translation_set, 'no-limit') as $entry) {
         $warnings = GP::$translation_warnings->check($entry->singular, $entry->plural, $entry->translations, $locale);
         if ($warnings != $entry->warnings) {
             $translation = new GP_Translation(array('id' => $entry->id));
             echo sprintf(__("Updating warnings for %s"), $entry->id) . "\n";
             $translation->update(array('warnings' => $warnings));
         }
     }
 }
コード例 #2
0
ファイル: translation-set.php プロジェクト: akirk/GlotPress
 /**
  * Recheck warnings for the translation set
  *
  * ## OPTIONS
  *
  * <project>
  * : Project path
  *
  * <locale>
  * : Locale to export
  *
  * [--set=<set>]
  * : Translation set slug; default is "default"
  *
  * @subcommand recheck-warnings
  */
 public function recheck_warnings($args, $assoc_args)
 {
     $set_slug = isset($assoc_args['set']) ? $assoc_args['set'] : 'default';
     $translation_set = $this->get_translation_set($args[0], $args[1], $set_slug);
     if (is_wp_error($translation_set)) {
         WP_CLI::error($translation_set->get_error_message());
     }
     $project = GP::$project->get($translation_set->project_id);
     $locale = GP_Locales::by_slug($translation_set->locale);
     foreach (GP::$translation->for_translation($project, $translation_set, 'no-limit') as $entry) {
         $warnings = GP::$translation_warnings->check($entry->singular, $entry->plural, $entry->translations, $locale);
         if ($warnings == $entry->warnings) {
             continue;
         }
         $translation = new GP_Translation(array('id' => $entry->id));
         /* translators: %s: ID of a translation */
         WP_CLI::line(sprintf(__('Updating warnings for #%s', 'glotpress'), $entry->id));
         $translation->update(array('warnings' => $warnings));
     }
 }