From 8f8fe44b05a464410ce2e2a797c96ec1f7d96c81 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 11 Feb 2015 13:02:11 -0800 Subject: [PATCH] Update arcanist to work with more modular translations Summary: Ref T7152. Ref T1139. - Tweak API. - Move translations out of __init__ file. Test Plan: - Ran `arc`. - Added a goofy translation and made sure it was working. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7152, T1139 Differential Revision: https://secure.phabricator.com/D11746 --- scripts/__init_script__.php | 58 ++--------------- src/__phutil_library_map__.php | 2 + .../ArcanistUSEnglishTranslation.php | 64 +++++++++++++++++++ 3 files changed, 70 insertions(+), 54 deletions(-) create mode 100644 src/internationalization/ArcanistUSEnglishTranslation.php diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php index cb55a290..8bbdf0fd 100644 --- a/scripts/__init_script__.php +++ b/scripts/__init_script__.php @@ -51,58 +51,8 @@ if (!@constant('__LIBPHUTIL__')) { exit(1); } -PhutilTranslator::getInstance() - ->addTranslations(array( - '%s 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:', - ), - 'These %s path(s) will NOT be committed. Commit this revision '. - 'anyway?' => array( - 'This path will NOT be committed. Commit this revision anyway?', - 'These paths will NOT be committed. Commit this revision anyway?', - ), - 'Revision includes changes to %s 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 %s 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.', - ), - '%d AFFECTED FILE(S)' => array('AFFECTED FILE', 'AFFECTED FILES'), - 'Do you want to mark these %s file(s) 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?', - ), - - 'Do you want to amend these %s file(s) to the commit?' => array( - 'Do you want to amend this file to the commit?', - 'Do you want to amend these files to the commit?', - ), - - 'Do you want to add these %s file(s) to the commit?' => array( - 'Do you want to add this file to the commit?', - 'Do you want to add these files to the commit?', - ), - - '%s line(s)' => array('line', 'lines'), - - '%d test(s)' => array('%d test', '%d tests'), - - '%d assertion(s) passed.' => array( - '%d assertion passed.', - '%d assertions passed.', - ), - )); - phutil_load_library(dirname(dirname(__FILE__)).'/src/'); + +PhutilTranslator::getInstance() + ->setLocale(PhutilLocale::loadLocale('en_US')) + ->setTranslations(PhutilTranslation::getTranslationMapForLocale('en_US')); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 1cab4f46..0a56871d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -184,6 +184,7 @@ phutil_register_library_map(array( 'ArcanistTextLinterTestCase' => 'lint/linter/__tests__/ArcanistTextLinterTestCase.php', 'ArcanistTimeWorkflow' => 'workflow/ArcanistTimeWorkflow.php', 'ArcanistTodoWorkflow' => 'workflow/ArcanistTodoWorkflow.php', + 'ArcanistUSEnglishTranslation' => 'internationalization/ArcanistUSEnglishTranslation.php', 'ArcanistUncommittedChangesException' => 'exception/usage/ArcanistUncommittedChangesException.php', 'ArcanistUnitConsoleRenderer' => 'unit/renderer/ArcanistUnitConsoleRenderer.php', 'ArcanistUnitRenderer' => 'unit/renderer/ArcanistUnitRenderer.php', @@ -367,6 +368,7 @@ phutil_register_library_map(array( 'ArcanistTextLinterTestCase' => 'ArcanistLinterTestCase', 'ArcanistTimeWorkflow' => 'ArcanistPhrequentWorkflow', 'ArcanistTodoWorkflow' => 'ArcanistWorkflow', + 'ArcanistUSEnglishTranslation' => 'PhutilTranslation', 'ArcanistUncommittedChangesException' => 'ArcanistUsageException', 'ArcanistUnitConsoleRenderer' => 'ArcanistUnitRenderer', 'ArcanistUnitTestableLintEngine' => 'ArcanistLintEngine', diff --git a/src/internationalization/ArcanistUSEnglishTranslation.php b/src/internationalization/ArcanistUSEnglishTranslation.php new file mode 100644 index 00000000..b6e8c387 --- /dev/null +++ b/src/internationalization/ArcanistUSEnglishTranslation.php @@ -0,0 +1,64 @@ + array( + 'A locally modified path is not included in this revision:', + 'Locally modified paths are not included in this revision:', + ), + 'These %s path(s) will NOT be committed. Commit this revision '. + 'anyway?' => array( + 'This path will NOT be committed. Commit this revision anyway?', + 'These paths will NOT be committed. Commit this revision anyway?', + ), + 'Revision includes changes to %s 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 %s 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.', + ), + '%d AFFECTED FILE(S)' => array('AFFECTED FILE', 'AFFECTED FILES'), + 'Do you want to mark these %s file(s) 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?', + ), + + 'Do you want to amend these %s file(s) to the commit?' => array( + 'Do you want to amend this file to the commit?', + 'Do you want to amend these files to the commit?', + ), + + 'Do you want to add these %s file(s) to the commit?' => array( + 'Do you want to add this file to the commit?', + 'Do you want to add these files to the commit?', + ), + + '%s line(s)' => array('line', 'lines'), + + '%d test(s)' => array('%d test', '%d tests'), + + '%d assertion(s) passed.' => array( + '%d assertion passed.', + '%d assertions passed.', + ), + ); + } + +}