Created
October 1, 2021 19:24
-
-
Save Derkades/e6aab6ffb311208c7a6f10eb9d56788b to your computer and use it in GitHub Desktop.
Script to duplicate minecraft language files for all languages in a resource pack
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
import json | |
import shutil | |
DOTMINECRAFT = '/home/robin/.minecraft' | |
VERSION = '1.17' | |
INPUT_FILE = 'lang.json' | |
OUTPUT_DIR = 'out/' | |
language_codes = [] | |
with open(f'{DOTMINECRAFT}/assets/indexes/{VERSION}.json') as f: | |
indexes: dict = json.load(f) | |
keys: [str] = indexes['objects'].keys() | |
for key in keys: | |
if key.startswith('minecraft/lang/'): | |
# remove minecraft/lang/ and .json | |
language_codes.append(key[15:-5]) | |
print(language_codes) | |
for code in language_codes: | |
shutil.copy(INPUT_FILE, f'{OUTPUT_DIR}/{code}.json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment