Universal-Bypass/.update_locales.php

51 lines
1015 B
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-02-04 01:00:35 +01:00
if(!file_exists("bypass.zip"))
{
die("bypass.zip not found.\n");
}
2019-01-15 02:42:23 +01:00
$zip = new ZipArchive();
$zip->open("bypass.zip") or die("Failed to open bypass.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");
2019-02-04 01:00:35 +01:00
if(file_get_contents("_locales/{$locale}/messages.json") == "{\n\n}")
2019-01-15 02:42:23 +01:00
{
recursivelyDelete("_locales/{$locale}");
continue;
}
2019-01-28 17:51:55 +01:00
if(in_array($locale, ["es-ES"]))
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();
unlink("bypass.zip");
mkdir("_locales/en");
rename("messages.json", "_locales/en/messages.json");