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

Extract `scripts` and `support` dirs alongside the library.

Summary:
Fixes T16387

I thought for a long time about how to do this, including at various points considering:
- Making the code work on directories instead of libraries
- Adding a `--nolib` or something like it to do that
- Adding a `--extradirs` argument instead of hardcoding `scripts` and `support`

In the end, though, I went with this. The reason is that this script has (AFAIK) two consumers:
- `bin/i18n validate` (from D26572)
- WMF downstream code to provide source strings to translatewiki.net

WMF downstream code doesn't care how it gets the strings to use (there's a script that passes various sets of arguments), but `bin/i18n validate` does. It works by taking all loaded libraries and running extractions on them, and assumes that provides all of the strings it cares about. For that to work, there has to be one canonical way to extract strings from a library, and this is it ...

Test Plan:
- Run `bin/i18n extract`
- See more strings inside `src/.cache/i18n_strings.json`

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

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

Maniphest Tasks: T16387

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

Pppery 785052ad b3bb110c

+14 -2
+14 -2
src/infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php
··· 208 208 } 209 209 210 210 private function loadLibraryFiles($root) { 211 - $files = id(new FileFinder($root)) 211 + $files = $this->loadDirectoryFiles($root); 212 + $extra_dirs = array('support', 'scripts'); 213 + foreach ($extra_dirs as $extra) { 214 + $extra = '..'.DIRECTORY_SEPARATOR.$extra.DIRECTORY_SEPARATOR; 215 + if (Filesystem::pathExists(Filesystem::resolvePath($root.$extra))) { 216 + $files = array_merge($files, $this->loadDirectoryFiles($root, $extra)); 217 + } 218 + } 219 + return $files; 220 + } 221 + 222 + private function loadDirectoryFiles($root, $suffix = '') { 223 + $files = id(new FileFinder($root.$suffix)) 212 224 ->withType('f') 213 225 ->withSuffix('php') 214 226 ->excludePath('*/.*') ··· 229 241 continue; 230 242 } 231 243 232 - $map[$file] = md5($hash.$file); 244 + $map[$suffix.$file] = md5($hash.$file); 233 245 } 234 246 235 247 return $map;