@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Separate locales into more usable groups in the translation menu

Summary:
Ref T5267. Ref T4103. Currently, adding new locale support to the upstream fills this menu with confusing options which don't do anything. Separate it into four groups:

- Translations: these have a "reasonable number" of strings and you'll probably see some obvious effect if you switch to the translation.
- Limited Translations: these have very few or no strings, and include locales which we've added but don't ship translations for.
- Silly Translations: Pirate english, etc.
- Test Translations: ALLCAPS, raw strings, etc.

Czech is currently in "test" instead of "limited" for historical reasons; I'll remedy this in the next change.

Test Plan: {F1661523}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4103, T5267

Differential Revision: https://secure.phabricator.com/D15978

+78 -23
+78 -23
src/applications/settings/panel/PhabricatorAccountSettingsPanel.php
··· 53 53 PhutilPerson::SEX_FEMALE => $label_her, 54 54 ); 55 55 56 - $locales = PhutilLocale::loadAllLocales(); 57 - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 58 - $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); 59 - 60 - $translations = array(); 61 - foreach ($locales as $locale) { 62 - if ($is_serious && $locale->isSillyLocale()) { 63 - // Omit silly locales on serious business installs. 64 - continue; 65 - } 66 - if (!$is_dev && $locale->isTestLocale()) { 67 - // Omit test locales on installs which aren't in development mode. 68 - continue; 69 - } 70 - $translations[$locale->getLocaleCode()] = $locale->getLocaleName(); 71 - } 72 - 73 - asort($translations); 74 - // TODO: Implement "locale.default" and use it here. 75 - $default = 'en_US'; 76 - $translations = array( 77 - '' => pht('Server Default: %s', $locales[$default]->getLocaleName()), 78 - ) + $translations; 56 + $translations = $this->getTranslationOptions(); 79 57 80 58 $form = new AphrontFormView(); 81 59 $form ··· 107 85 $form_box, 108 86 ); 109 87 } 88 + 89 + private function getTranslationOptions() { 90 + $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 91 + $locales = PhutilLocale::loadAllLocales(); 92 + 93 + $group_labels = array( 94 + 'normal' => pht('Translations'), 95 + 'limited' => pht('Limited Translations'), 96 + 'silly' => pht('Silly Translations'), 97 + 'test' => pht('Developer/Test Translations'), 98 + ); 99 + 100 + $groups = array_fill_keys(array_keys($group_labels), array()); 101 + 102 + $translations = array(); 103 + foreach ($locales as $locale) { 104 + $code = $locale->getLocaleCode(); 105 + $name = $locale->getLocaleName(); 106 + 107 + if ($locale->isSillyLocale()) { 108 + if ($is_serious) { 109 + // Omit silly locales on serious business installs. 110 + continue; 111 + } 112 + $groups['silly'][$code] = $name; 113 + continue; 114 + } 115 + 116 + if ($locale->isTestLocale()) { 117 + $groups['test'][$code] = $name; 118 + continue; 119 + } 120 + 121 + $strings = PhutilTranslation::getTranslationMapForLocale($code); 122 + $size = count($strings); 123 + 124 + // If a translation is English, assume it can fall back to the default 125 + // strings and don't caveat its completeness. 126 + $is_english = (substr($code, 0, 3) == 'en_'); 127 + 128 + // Arbitrarily pick some number of available strings to promote a 129 + // translation out of the "limited" group. The major goal is just to 130 + // keep locales with very few strings out of the main group, so users 131 + // aren't surprised if a locale has no upstream translations available. 132 + if ($size > 512 || $is_english) { 133 + $type = 'normal'; 134 + } else { 135 + $type = 'limited'; 136 + } 137 + 138 + $groups[$type][$code] = $name; 139 + } 140 + 141 + // TODO: Select a default properly. 142 + $default = 'en_US'; 143 + 144 + $results = array(); 145 + foreach ($groups as $key => $group) { 146 + $label = $group_labels[$key]; 147 + if (!$group) { 148 + continue; 149 + } 150 + 151 + asort($group); 152 + 153 + if ($key == 'normal') { 154 + $group = array( 155 + '' => pht('Server Default: %s', $locales[$default]->getLocaleName()), 156 + ) + $group; 157 + } 158 + 159 + $results[$label] = $group; 160 + } 161 + 162 + return $results; 163 + } 164 + 110 165 }