@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.

Add a test to make sure the i18n validator passes

Test Plan: Run `arc unit`

Reviewers: O1 Blessed Committers, aklapper, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D26704

Pppery 60c3cda9 ca14ece8

+38 -15
+2
src/__phutil_library_map__.php
··· 5412 5412 'PhorgeCodeWarningSetupCheck' => 'applications/config/check/PhorgeCodeWarningSetupCheck.php', 5413 5413 'PhorgeFlagFlaggedObjectCustomField' => 'applications/flag/customfield/PhorgeFlagFlaggedObjectCustomField.php', 5414 5414 'PhorgeFlagFlaggedObjectFieldStorage' => 'applications/flag/customfield/PhorgeFlagFlaggedObjectFieldStorage.php', 5415 + 'PhorgeI18nTestCase' => '__tests__/PhorgeI18nTestCase.php', 5415 5416 'PhorgeInternationalizationManagementValidateWorkflow' => 'infrastructure/internationalization/management/PhorgeInternationalizationManagementValidateWorkflow.php', 5416 5417 'PhorgeInternationalizationValidator' => 'infrastructure/internationalization/management/PhorgeInternationalizationValidator.php', 5417 5418 'PhorgePHPASTParseTree' => 'applications/phpast/storage/PhorgePHPASTParseTree.php', ··· 12286 12287 'PhorgeCodeWarningSetupCheck' => 'PhabricatorSetupCheck', 12287 12288 'PhorgeFlagFlaggedObjectCustomField' => 'PhabricatorCustomField', 12288 12289 'PhorgeFlagFlaggedObjectFieldStorage' => 'Phobject', 12290 + 'PhorgeI18nTestCase' => 'PhabricatorTestCase', 12289 12291 'PhorgeInternationalizationManagementValidateWorkflow' => 'PhabricatorInternationalizationManagementWorkflow', 12290 12292 'PhorgeInternationalizationValidator' => 'Phobject', 12291 12293 'PhorgePHPASTParseTree' => 'PhabricatorXHPASTDAO',
+12
src/__tests__/PhorgeI18nTestCase.php
··· 1 + <?php 2 + 3 + final class PhorgeI18nTestCase extends PhabricatorTestCase { 4 + public function testi18nValidation() { 5 + $validator = new PhorgeInternationalizationValidator(); 6 + $errors = $validator->validateLibraries( 7 + $validator->loadExtractions(true, true)); 8 + $this->assertEqual(array(), 9 + $errors, 10 + pht('i18n validation errors found!')); 11 + } 12 + }
+24 -15
src/infrastructure/internationalization/management/PhorgeInternationalizationValidator.php
··· 14 14 new PhutilNumber($n + 1), 15 15 phutil_count($types)); 16 16 } 17 - $data = []; 17 + $data = array(); 18 18 foreach ($types as $type) { 19 19 if ($type === 'phutilnumber') { 20 20 // Make a class that can be converted into a string ··· 93 93 return $errors; 94 94 } 95 95 public function validateLibraries($loaded_json) { 96 - $errors = []; 96 + $errors = array(); 97 97 $all_translations = PhutilTranslation::getAllTranslations(); 98 98 $locales = PhutilLocale::loadAllLocales(); 99 - $keyed_translations = []; 99 + $keyed_translations = array(); 100 100 $override_key = 'translation.override'; 101 101 try { 102 102 $trans_override = PhabricatorEnv::getEnvConfig($override_key); ··· 164 164 } 165 165 return $errors; 166 166 } 167 - public function loadExtractions($run_extractor) { 167 + public function loadExtractions($run_extractor, $quiet = false) { 168 168 $libraries = PhutilBootloader::getInstance()->getAllLibraries(); 169 169 $phorge_root = phutil_get_library_root('phorge'); 170 - $i18n_bin = $phorge_root.'/../bin/i18n'; 171 - $all_json = []; 170 + $i18n_bin = Filesystem::resolvePath('../bin/i18n', $phorge_root); 171 + $all_json = array(); 172 172 foreach ($libraries as $lib) { 173 173 $root = phutil_get_library_root($lib); 174 - $json = Filesystem::resolvePath($root.'/.cache/i18n_strings.json'); 174 + $json = Filesystem::resolvePath('.cache/i18n_strings.json', $root); 175 175 if ($run_extractor) { 176 - $err = phutil_passthru( 177 - '%R extract %s', 178 - $i18n_bin, 179 - $root); 180 - if ($err) { 181 - throw new Exception(pht( 182 - 'Failed to run i18n extractor: %s', 183 - $err)); 176 + // The command needs to be stated twice to avoid the linter complaining 177 + // about the arg not being a scalar string 178 + if ($quiet) { 179 + execx( 180 + '%R extract %s', 181 + $i18n_bin, 182 + $root); 183 + } else { 184 + $err = phutil_passthru( 185 + '%R extract %s', 186 + $i18n_bin, 187 + $root); 188 + if ($err) { 189 + throw new Exception(pht( 190 + 'Failed to run i18n extractor: %s', 191 + $err)); 192 + } 184 193 } 185 194 } else if (!Filesystem::pathExists($json)) { 186 195 throw new Exception(pht(