forked from FastForwardTeam/FastForward
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.update_locales.php
76 lines (75 loc) · 1.91 KB
/
.update_locales.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
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
<?php
function recursivelyDelete($file)
{
if(is_dir($file))
{
foreach(scandir($file) as $child)
{
if(!in_array($child, [".", ".."]))
{
recursivelyDelete($file."/".$child);
}
}
rmdir($file);
}
else
{
unlink($file);
}
}
if(!file_exists("FastForward (translations).zip"))
{
die("FastForward (translations).zip not found.\n");
}
$zip = new ZipArchive();
$zip->open("FastForward (translations).zip") or die("Failed to open FastForward (translations).zip\n");
rename("_locales/en/messages.json", "messages.json");
recursivelyDelete("_locales");
$zip->extractTo("_locales");
foreach(scandir("_locales") as $locale)
{
if(in_array($locale, [".", ".."]))
{
continue;
}
unlink("_locales/{$locale}/marketing.json");
$cont = file_get_contents("_locales/{$locale}/messages.json");
if(rtrim($cont) == "{}")
{
recursivelyDelete("_locales/{$locale}");
continue;
}
$json = json_decode($cont, true);
foreach($json as $key => $data)
{
if(in_array($key, ["bypassCounter", "optionsNavigationDelay", "optionsCrowdAutoOpen", "optionsCrowdAutoClose", "beforeNavigateDestination", "beforeNavigateTimer", "beforeNavigateUnsafeTimer", "beforeNavigateInstant", "crowdBypassedInfo", "crowdBypassedTimer", "crowdCloseTimer"]))
{
if(strpos($data["message"], "%") === false)
{
echo "$key in $locale is missing %\n";
}
}
else
{
if(strpos($data["message"], "%") !== false)
{
echo "$key in $locale has a superfluous %\n";
}
}
if(in_array($key, ["infoLinkvertise","infoFileHoster","infoOutdated","crowdWait","crowdDisabled"]))
{
if(strpos($data["message"], "\n") !== false)
{
echo "$key in $locale has a new line character\n";
}
}
}
if(in_array($locale, ["es-ES", "br-FR"]))
{
rename("_locales/{$locale}", "_locales/".substr($locale, 0, 2));
}
}
$zip->close();
unlink("FastForward (translations).zip");
mkdir("_locales/en");
rename("messages.json", "_locales/en/messages.json");