Skip to content

Instantly share code, notes, and snippets.

@Derkades
Created October 1, 2021 19:24
Show Gist options
  • Save Derkades/e6aab6ffb311208c7a6f10eb9d56788b to your computer and use it in GitHub Desktop.
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
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