Universal-Bypass/.update_locales.php

51 lines
1.1 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");
2019-11-21 09:27:50 +01:00
if(rtrim(file_get_contents("_locales/{$locale}/messages.json")) == "{}")
2019-01-15 02:42:23 +01:00
{
recursivelyDelete("_locales/{$locale}");
continue;
}
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");