forked from statamic/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator
126 lines (116 loc) · 3.56 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/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',
'moment',
];
// 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:",
"If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\ninto your web browser:", // laravel <8.48.0
'All rights reserved.',
'The given data was invalid.',
'Protected Page',
];
// 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',
'password_protect_enter_password',
'password_protect_token_missing',
],
'fieldtypes' => [
'array.title',
'assets.title',
'bard.title',
'button_group.title',
'checkboxes.title',
'code.title',
'collections.title',
'color.title',
'date.title',
'entries.title',
'float.title',
'form.title',
'grid.title',
'group.title',
'hidden.title',
'html.title',
'icon.title',
'integer.title',
'link.title',
'list.title',
'markdown.title',
'radio.title',
'range.title',
'replicator.title',
'revealer.title',
'section.title',
'select.title',
'sites.title',
'structures.title',
'slug.title',
'table.title',
'taggable.title',
'terms.title',
'taxonomies.title',
'template.title',
'text.title',
'textarea.title',
'time.title',
'toggle.title',
'user_groups.title',
'user_roles.title',
'users.title',
'video.title',
'yaml.title',
],
];
// 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();