]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Update arcanist to work with more modular translations
authorepriestley <git@epriestley.com>
Wed, 11 Feb 2015 21:02:11 +0000 (13:02 -0800)
committerepriestley <git@epriestley.com>
Wed, 11 Feb 2015 21:02:11 +0000 (13:02 -0800)
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
src/__phutil_library_map__.php
src/internationalization/ArcanistUSEnglishTranslation.php [new file with mode: 0644]

index cb55a29019dc90274a62ede5ce0c4c9ce746501a..8bbdf0fd7d4b96962c2927f8b5a43118459815aa 100644 (file)
@@ -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'));
index 1cab4f460bc8f38e35e2561175264428a181c8b5..0a56871d08c4c2e2bcb53b87f25226de9712c6d9 100644 (file)
@@ -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 (file)
index 0000000..b6e8c38
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+final class ArcanistUSEnglishTranslation extends PhutilTranslation {
+
+  public function getLocaleCode() {
+    return 'en_US';
+  }
+
+  protected function getTranslations() {
+    return 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.',
+      ),
+    );
+  }
+
+}