From ae0773b78901c6eacd2be8ef950c71c74a8a33c9 Mon Sep 17 00:00:00 2001 From: Ricky Elrod Date: Fri, 4 Jan 2013 16:22:52 -0800 Subject: [PATCH] Add translations config group. Summary: Adds the translations group as per T2255. Currently `translation.override` is `wild` -- it should be changed to dict when that exists. Also fixes a small bug from D4326 which caused "class" types to not ever validate. Test Plan: - Looked at the settings. - Successfully saved a setting relating to classes. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2255 Differential Revision: https://secure.phabricator.com/D4350 --- src/__phutil_library_map__.php | 2 + .../PhabricatorConfigEditController.php | 2 +- .../PhabricatorTranslationsConfigOptions.php | 43 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/applications/config/option/PhabricatorTranslationsConfigOptions.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2af565705e..395914be34 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1217,6 +1217,7 @@ phutil_register_library_map(array( 'PhabricatorTransactions' => 'applications/transactions/constants/PhabricatorTransactions.php', 'PhabricatorTransformedFile' => 'applications/files/storage/PhabricatorTransformedFile.php', 'PhabricatorTranslation' => 'infrastructure/internationalization/PhabricatorTranslation.php', + 'PhabricatorTranslationsConfigOptions' => 'applications/config/option/PhabricatorTranslationsConfigOptions.php', 'PhabricatorTrivialTestCase' => 'infrastructure/testing/__tests__/PhabricatorTrivialTestCase.php', 'PhabricatorTypeaheadCommonDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php', 'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadDatasourceController.php', @@ -2518,6 +2519,7 @@ phutil_register_library_map(array( 'PhabricatorTimer' => 'PhabricatorCountdownDAO', 'PhabricatorTransactionView' => 'AphrontView', 'PhabricatorTransformedFile' => 'PhabricatorFileDAO', + 'PhabricatorTranslationsConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorTrivialTestCase' => 'PhabricatorTestCase', 'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController', 'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController', diff --git a/src/applications/config/controller/PhabricatorConfigEditController.php b/src/applications/config/controller/PhabricatorConfigEditController.php index 14c88b2c9a..56668d4eb3 100644 --- a/src/applications/config/controller/PhabricatorConfigEditController.php +++ b/src/applications/config/controller/PhabricatorConfigEditController.php @@ -361,7 +361,7 @@ final class PhabricatorConfigEditController ->setConcreteOnly(true) ->selectSymbolsWithoutLoading(); $names = ipull($symbols, 'name', 'name'); - sort($names); + asort($names); $names = array( '' => pht('(Use Default)'), ) + $names; diff --git a/src/applications/config/option/PhabricatorTranslationsConfigOptions.php b/src/applications/config/option/PhabricatorTranslationsConfigOptions.php new file mode 100644 index 0000000000..e3392a1302 --- /dev/null +++ b/src/applications/config/option/PhabricatorTranslationsConfigOptions.php @@ -0,0 +1,43 @@ +newOption( + 'translation.provider', + 'class', + 'PhabricatorEnglishTranslation') + ->setBaseClass('PhabricatorTranslation') + ->setSummary(pht("Translation class that should be used for strings.")) + ->setDescription( + pht( + "This allows customizing texts used in Phabricator. The class ". + "must extend PhabricatorTranslation.")) + ->addExample('PhabricatorEnglishTranslation', pht('Valid Setting')), + // TODO: This should be dict I think, but that doesn't + // exist yet. + $this->newOption('translation.override', 'wild', array()) + ->setSummary(pht("Override translations.")) + ->setDescription( + pht( + "You can use 'translation.override' if you don't want to create ". + "a full translation to give users an option for switching to it ". + "and you just want to override some strings in the default ". + "translation.")) + ->addExample( + '{"some string": "my alternative"}', + pht('Valid Setting')), + ); + } + +}