/
oneskyapp.php
executable file
·44 lines (29 loc) · 988 Bytes
/
oneskyapp.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
#!/usr/bin/env php
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Onesky\Api\Client;
use Zend\Json\Json;
if (! isset($argv[1]) || ! $argv[1]) {
throw new Exception("Secret not provided");
}
$languages = ['en', 'zh', 'ru', 'pt-br', 'fr', 'be', 'uk', 'es', 'it'];
$projectID = 129670;
$client = new Client();
$client
->setApiKey("2a1C12oZU5VIK409AJd0xUfVntGyhLWa")
->setSecret($argv[1]);
$backendDir = realpath(__DIR__ . '/module/Application/language');
foreach ($languages as $language) {
$response = $client->translations('export', [
'project_id' => $projectID,
'locale' => $language,
'source_file_name' => 'frontend.json',
]);
$data = Json::decode($response, Json::TYPE_ARRAY);
$content = '<?php return ' . var_export($data, true) . ';';
$filepath = $backendDir . '/' . $language . '.php';
print $filepath . "\n";
file_put_contents($filepath, $content);
}
return "done\n";