|
21 | 21 |
|
22 | 22 | class SyncFileList |
23 | 23 | { |
24 | | - static function load() |
| 24 | + static function load( ?string $lang = null , array $files = [] ) |
25 | 25 | { |
26 | | - $file = __DIR__ . "/../../../temp/lang"; |
27 | | - if ( ! file_exists( $file ) ) |
| 26 | + if ( $lang === null ) |
28 | 27 | { |
29 | | - fwrite( STDERR , "Language file not found, run 'doc-base/configure.php'.\n" ); |
30 | | - exit(); |
| 28 | + $file = __DIR__ . "/../../../temp/lang"; |
| 29 | + if ( ! file_exists( $file ) ) |
| 30 | + { |
| 31 | + fwrite( STDERR , "Language not found, run 'doc-base/configure.php' or use '--lang='.\n" ); |
| 32 | + exit(); |
| 33 | + } |
| 34 | + $lang = trim( file_get_contents( $file ) ); |
| 35 | + } |
| 36 | + |
| 37 | + $sourceDir = 'en'; |
| 38 | + $targetDir = $lang; |
| 39 | + |
| 40 | + if ( count( $files ) > 0 ) |
| 41 | + { |
| 42 | + $ret = []; |
| 43 | + |
| 44 | + foreach ( $files as $file ) |
| 45 | + { |
| 46 | + if ( ! file_exists( "$targetDir/$file" ) ) |
| 47 | + continue; |
| 48 | + |
| 49 | + $item = new SyncFileItem(); |
| 50 | + $item->sourceDir = $sourceDir; |
| 51 | + $item->targetDir = $targetDir; |
| 52 | + $item->file = $file; |
| 53 | + $ret[] = $item; |
| 54 | + } |
| 55 | + |
| 56 | + if ( $ret === [] ) |
| 57 | + throw new Exception( "No matching files found." ); |
| 58 | + |
| 59 | + return $ret; |
31 | 60 | } |
32 | 61 |
|
33 | | - $lang = trim( file_get_contents( $file ) ); |
34 | 62 | $cacheFilename = __DIR__ . "/../../../temp/qaxml.files.$lang"; |
35 | 63 |
|
36 | 64 | if ( file_exists( $cacheFilename ) ) |
37 | 65 | { |
38 | 66 | return unserialize( gzdecode( file_get_contents( $cacheFilename ) ) ); |
39 | 67 | } |
40 | 68 |
|
41 | | - $sourceDir = 'en'; |
42 | | - $targetDir = $lang; |
43 | | - |
44 | 69 | require_once __DIR__ . '/../lib/all.php'; |
45 | 70 |
|
46 | | - $files = new RevcheckFileList( $sourceDir ); |
| 71 | + $revFiles = new RevcheckFileList( $sourceDir ); |
47 | 72 | $ret = []; |
48 | 73 |
|
49 | | - foreach( $files->iterator() as $file ) |
| 74 | + foreach( $revFiles->iterator() as $file ) |
50 | 75 | { |
51 | 76 | if ( ! file_exists( "$targetDir/{$file->file}" ) ) |
52 | 77 | continue; |
|
0 commit comments