Universal-Bypass/.update_locales.php

60 lines
1.4 KiB
PHP
Raw Normal View History

2019-01-15 02:42:23 +01:00
<?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);
}
}
2019-10-02 15:49:38 +02:00
if(!file_exists("Universal Bypass.zip"))
2019-02-04 01:00:35 +01:00
{
2019-10-02 15:49:38 +02:00
die("Universal Bypass.zip not found.\n");
2019-02-04 01:00:35 +01:00
}
2019-01-15 02:42:23 +01:00
$zip = new ZipArchive();
2019-10-02 15:49:38 +02:00
$zip->open("Universal Bypass.zip") or die("Failed to open Universal Bypass.zip\n");
2019-01-15 02:42:23 +01:00
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");
2020-01-21 15:46:05 +01:00
$cont = file_get_contents("_locales/{$locale}/messages.json");
if(rtrim($cont) == "{}")
2019-01-15 02:42:23 +01:00
{
recursivelyDelete("_locales/{$locale}");
continue;
}
2020-01-21 15:46:05 +01:00
$json = json_decode($cont, true);
foreach(["bypassCounter", "optionsNavigationDelay", "optionsCrowdAutoOpen", "beforeNavigateDestination", "beforeNavigateTimer", "crowdBypassedInfo", "crowdBypassedTimer"] as $key)
{
if(array_key_exists($key, $json) && strpos($json[$key]["message"], "%") === false)
{
echo "$key in $locale is missing %\n";
}
}
2019-08-19 18:03:56 +02:00
if(in_array($locale, ["es-ES", "br-FR"]))
2019-01-15 02:42:23 +01:00
{
2019-01-28 17:51:55 +01:00
rename("_locales/{$locale}", "_locales/".substr($locale, 0, 2));
}
2019-01-15 02:42:23 +01:00
}
$zip->close();
2019-10-02 15:49:38 +02:00
unlink("Universal Bypass.zip");
2019-01-15 02:42:23 +01:00
mkdir("_locales/en");
rename("messages.json", "_locales/en/messages.json");