Created
October 3, 2018 06:17
-
-
Save simon511000/c5d608ccf010f72302d38bd19d26bad3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
$advancements = "datapack/data/mechanization/advancements"; | |
function translate($dir,$prefix2=""){ | |
$prefix = "mech.advancements."; | |
$dir2 = opendir($dir); | |
while($file = readdir($dir2)){ | |
if($file != '.' && $file != '..' && strstr($file,".json")) | |
{ | |
$en = json_decode(file_get_contents("ressourcepack/assets/mechanization/lang/en_us.json"),true); | |
$fr = json_decode(file_get_contents("ressourcepack/assets/mechanization/lang/fr_fr.json"),true); | |
$filedir = $dir."/".$file; | |
$translate = json_decode(file_get_contents($filedir),true); | |
$title = $translate["display"]["title"]; | |
$description = $translate["display"]["description"]; | |
$translated = $translate; | |
$translated["display"]["title"] = ["translate"=>$prefix.$prefix2.basename($file,".json").".title"]; | |
$en[$prefix.$prefix2.basename($file,".json").".title"] = $title; | |
$fr[$prefix.$prefix2.basename($file,".json").".title"] = $title; | |
$translated["display"]["description"] = ["translate"=>$prefix.$prefix2.basename($file,".json").".description"]; | |
$en[$prefix.$prefix2.basename($file,".json").".description"] = $description; | |
$fr[$prefix.$prefix2.basename($file,".json").".description"] = $description; | |
file_put_contents("ressourcepack/assets/mechanization/lang/en_us.json",json_encode($en)); | |
file_put_contents("ressourcepack/assets/mechanization/lang/fr_fr.json",json_encode($fr)); | |
file_put_contents($filedir,json_encode($translated)); | |
} | |
} | |
closedir($dir2); | |
} | |
translate($advancements); | |
translate($advancements."/base","base."); | |
translate($advancements."/machines","machines."); | |
translate($advancements."/nuclear","nuclear."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment