From 57499106ec5c1d7f2cde6fdc106bffcf62cd1bc6 Mon Sep 17 00:00:00 2001 From: vrana Date: Mon, 11 Jun 2012 18:33:19 -0700 Subject: [PATCH] Use pht() Test Plan: `arc cover` Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1139 Differential Revision: https://secure.phabricator.com/D2716 --- scripts/__init_script__.php | 36 +++++++++++++++++++++++++ src/workflow/ArcanistCommitWorkflow.php | 24 +++++++---------- src/workflow/ArcanistCoverWorkflow.php | 2 +- src/workflow/ArcanistDiffWorkflow.php | 32 ++++++++-------------- 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php index c099d526..70708eca 100644 --- a/scripts/__init_script__.php +++ b/scripts/__init_script__.php @@ -28,4 +28,40 @@ if (!@constant('__LIBPHUTIL__')) { exit(1); } +PhutilTranslator::getInstance() + ->addTranslations(array( + 'Locally modified path(s) are not included in this revision:' => array( + 'A locally modified path is not included in this revision:', + 'Locally modified paths are not included in this revision:', + ), + 'They will NOT be committed. Commit this revision anyway?' => array( + 'It will NOT be committed. Commit this revision anyway?', + 'They will NOT be committed. Commit this revision anyway?', + ), + 'Revision includes changes to path(s) that do not exist:' => array( + 'Revision includes changes to a path that does not exist:', + 'Revision includes changes to paths that do not exist:', + ), + + 'This diff includes file(s) which are not valid UTF-8 (they contain '. + 'invalid byte sequences). You can either stop this workflow and fix '. + 'these files, or continue. If you continue, these files will be '. + 'marked as binary.' => array( + 'This diff includes a file which is not valid UTF-8 (it has invalid '. + 'byte sequences). You can either stop this workflow and fix it, or '. + 'continue. If you continue, this file will be marked as binary.', + 'This diff includes files which are not valid UTF-8 (they contain '. + 'invalid byte sequences). You can either stop this workflow and fix '. + 'these files, or continue. If you continue, these files will be '. + 'marked as binary.', + ), + 'AFFECTED FILE(S)' => array('AFFECTED FILE', 'AFFECTED FILES'), + 'Do you want to mark these files as binary and continue?' => array( + 'Do you want to mark this file as binary and continue?', + 'Do you want to mark these files as binary and continue?', + ), + + 'line(s)' => array('line', 'lines'), + )); + phutil_load_library(dirname(dirname(__FILE__)).'/src/'); diff --git a/src/workflow/ArcanistCommitWorkflow.php b/src/workflow/ArcanistCommitWorkflow.php index cfdc45c5..eb4a18c9 100644 --- a/src/workflow/ArcanistCommitWorkflow.php +++ b/src/workflow/ArcanistCommitWorkflow.php @@ -227,13 +227,12 @@ EOTEXT } if ($modified_but_not_included) { - if (count($modified_but_not_included) == 1) { - $prefix = "A locally modified path is not included in this revision:"; - $prompt = "It will NOT be committed. Commit this revision anyway?"; - } else { - $prefix = "Locally modified paths are not included in this revision:"; - $prompt = "They will NOT be committed. Commit this revision anyway?"; - } + $prefix = pht( + 'Locally modified path(s) are not included in this revision:', + count($modified_but_not_included)); + $prompt = pht( + 'They will NOT be committed. Commit this revision anyway?', + count($modified_but_not_included)); $this->promptFileWarning($prefix, $prompt, $modified_but_not_included); } @@ -254,13 +253,10 @@ EOTEXT } if ($do_not_exist) { - if (count($do_not_exist) == 1) { - $prefix = "Revision includes changes to a path that does not exist:"; - $prompt = "Commit this revision anyway?"; - } else { - $prefix = "Revision includes changes to paths that do not exist:"; - $prompt = "Commit this revision anyway?"; - } + $prefix = pht( + 'Revision includes changes to path(s) that do not exist:', + count($do_not_exist)); + $prompt = "Commit this revision anyway?"; $this->promptFileWarning($prefix, $prompt, $do_not_exist); } diff --git a/src/workflow/ArcanistCoverWorkflow.php b/src/workflow/ArcanistCoverWorkflow.php index 53c95f02..12e8f399 100644 --- a/src/workflow/ArcanistCoverWorkflow.php +++ b/src/workflow/ArcanistCoverWorkflow.php @@ -135,7 +135,7 @@ EOTEXT "**%s**\n", $author); foreach ($files as $file => $info) { - $line_noun = count($info['lines']) == 1 ? 'line' : 'lines'; + $line_noun = pht('line(s)', count($info['lines'])); $lines = $this->readableSequenceFromLineNumbers($info['lines']); echo " {$file}: {$line_noun} {$lines}\n"; } diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 28f4bdd9..48404bca 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -847,31 +847,21 @@ EOTEXT // and treat them as binary changes. See D327 for discussion of why Arcanist // has this behavior. if ($utf8_problems) { - $learn_more = + $utf8_warning = + pht( + "This diff includes file(s) which are not valid UTF-8 (they contain ". + "invalid byte sequences). You can either stop this workflow and ". + "fix these files, or continue. If you continue, these files will ". + "be marked as binary.", + count($utf8_problems))."\n\n". "You can learn more about how Phabricator handles character encodings ". "(and how to configure encoding settings and detect and correct ". "encoding problems) by reading 'User Guide: UTF-8 and Character ". "Encoding' in the Phabricator documentation.\n\n"; - if (count($utf8_problems) == 1) { - $utf8_warning = - "This diff includes a file which is not valid UTF-8 (it has invalid ". - "byte sequences). You can either stop this workflow and fix it, or ". - "continue. If you continue, this file will be marked as binary.\n\n". - $learn_more. - " AFFECTED FILE\n"; - - $confirm = "Do you want to mark this file as binary and continue?"; - } else { - $utf8_warning = - "This diff includes files which are not valid UTF-8 (they contain ". - "invalid byte sequences). You can either stop this workflow and fix ". - "these files, or continue. If you continue, these files will be ". - "marked as binary.\n\n". - $learn_more. - " AFFECTED FILES\n"; - - $confirm = "Do you want to mark these files as binary and continue?"; - } + " ".pht('AFFECTED FILE(S)', count($utf8_problems))."\n"; + $confirm = pht( + 'Do you want to mark these files as binary and continue?', + count($utf8_problems)); echo phutil_console_format("**Invalid Content Encoding (Non-UTF8)**\n"); echo phutil_console_wrap($utf8_warning); -- 2.43.0