forked from Azuriom/Azuriom
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crowdin_export.php
46 lines (33 loc) · 1.45 KB
/
crowdin_export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use Symfony\Component\Filesystem\Filesystem;
require_once 'vendor/autoload.php';
// To use this small script, just download the translations from Crowdin
// and place the unzipped folder in the same directory, and rename it
// as "crowdin_translations".
// The successfully translated locales (currently for >95% completed)
$locales = ['de', 'es-ES', 'fi', 'sv-SE', 'pl', 'ru', 'zh-CN', 'ko', 'pt-BR', 'cs', 'ca', 'uk', 'hu', 'id'];
if (! is_dir('crowdin_translations')) {
exit('The Crowdin translations must be in the "crowdin_translations" folder.');
}
$files = new Filesystem();
foreach ($locales as $locale) {
$origin = 'crowdin_translations/'.$locale;
$target = 'resources/lang/'.str_replace('-', '_', $locale);
$targetExtensions = $target.'/extensions';
$options = ['override' => true];
if (! is_dir($origin)) {
continue;
}
$files->mirror($origin.'/Azuriom', $target, null, $options);
$files->mirror($origin.'/Plugins', $targetExtensions, null, $options);
$files->mirror($origin.'/Themes', $targetExtensions, null, $options);
foreach (new DirectoryIterator($targetExtensions) as $file) {
if ($file->isDot()) {
continue;
}
$currentName = $targetExtensions.'/'.$file->getFilename();
$newName = $targetExtensions.'/'.strtolower($file->getFilename());
$files->rename($currentName, $newName, true);
}
}
echo 'Translations successfully exported!'.PHP_EOL;