forked from statamic/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator
75 lines (65 loc) · 2.23 KB
/
translator
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env php
<?php
require __DIR__.'/vendor/autoload.php';
$files = new Illuminate\Filesystem\Filesystem;
$discovery = new Statamic\Translator\MethodDiscovery($files, [
__DIR__.'/src',
__DIR__.'/resources/js',
__DIR__.'/resources/views'
]);
// Translation strings starting with these substrings will be ignored.
$ignoredSubstrings = [
'permissions.',
'statamic::permissions.',
];
// These files will not be generated from method discovery, but they will be
// copied to the other languages from English.
$manualFiles = [
'permissions',
'markdown',
'validation',
];
// Don't translate the following files.
$dontTranslate = [
'markdown',
];
// Additional strings to be translated that aren't picked up by the scanner.
// eg. When variables as passed into translation helpers, like nav items.
$additionalStrings = [
'Author',
'Content',
'Groups',
'Tools',
'Laptop',
'Tablet',
'Mobile',
'Hello!',
'Whoops!',
'Regards',
"If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser:",
'All rights reserved.',
'The given data was invalid.',
];
// Additional keys to be translated that aren't picked up by the scanner.
// eg. concatenated keys, like licensing errors.
$additionalKeys = [
'messages' => [
'licensing_error_unlicensed',
'licensing_error_invalid_domain',
'licensing_error_no_domains',
'licensing_error_outside_license_range',
'licensing_error_no_site_key',
'licensing_error_unknown_site',
],
];
// Translation keys that may get picked up but shouldn't.
// Really just a way to prevent parts of concatenated keys from being included.
$excludedKeys = [
'messages' => ['licensing_error_'],
];
$app = new Symfony\Component\Console\Application('Statamic Translator');
$app->add(new Statamic\Translator\Commands\Stats($discovery, $ignoredSubstrings));
$app->add(new Statamic\Translator\Commands\Generate($discovery, $files, $manualFiles, $ignoredSubstrings, $additionalStrings, $additionalKeys, $excludedKeys));
$app->add(new Statamic\Translator\Commands\Translate($files, $dontTranslate));
$app->add(new Statamic\Translator\Commands\Review($files));
$app->run();