-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
123 lines (101 loc) · 4.79 KB
/
index.py
File metadata and controls
123 lines (101 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import json
import os
import shutil
from pathlib import Path
# EDIT THIS TO YOUR SOURCE FILE NAME
# This is the source file that will be copied to all other language files
SOURCE_FILE = "en_us.json"
def copy_en_us_to_all_languages():
"""
Copies en_us.json to all other Minecraft language files.
"""
language_files = [
"af_za.json", "ar_sa.json", "ast_es.json", "az_az.json", "bar.json",
"ba_ru.json", "be_by.json", "be_latn.json", "bg_bg.json", "brb.json",
"br_fr.json", "bs_ba.json", "ca_es.json", "cs_cz.json", "cy_gb.json",
"da_dk.json", "de_at.json", "de_ch.json", "de_de.json", "el_gr.json",
"enp.json", "enws.json", "en_au.json", "en_ca.json", "en_gb.json",
"en_nz.json", "en_pt.json", "en_ud.json", "en_us.json", "eo_uy.json",
"esan.json", "es_ar.json", "es_cl.json", "es_ec.json", "es_es.json",
"es_mx.json", "es_uy.json", "es_ve.json", "et_ee.json", "eu_es.json",
"fa_ir.json", "fil_ph.json", "fi_fi.json", "fo_fo.json", "fra_de.json",
"fr_ca.json", "fr_fr.json", "fur_it.json", "fy_nl.json", "ga_ie.json",
"gd_gb.json", "gl_es.json", "haw_us.json", "he_il.json", "hi_in.json",
"hn_no.json", "hr_hr.json", "hu_hu.json", "hy_am.json", "id_id.json",
"ig_ng.json", "io_en.json", "isv.json", "is_is.json", "it_it.json",
"ja_jp.json", "jbo_en.json", "ka_ge.json", "kk_kz.json", "kn_in.json",
"ko_kr.json", "ksh.json", "kw_gb.json", "ky_kg.json", "la_la.json",
"lb_lu.json", "li_li.json", "lmo.json", "lol_us.json", "lo_la.json",
"lt_lt.json", "lv_lv.json", "lzh.json", "mk_mk.json", "mn_mn.json",
"ms_my.json", "mt_mt.json", "nah.json", "nds_de.json", "nl_be.json",
"nl_nl.json", "nn_no.json", "no_no.json", "oc_fr.json", "ovd.json",
"pls.json", "pl_pl.json", "pt_br.json", "pt_pt.json", "qya_aa.json",
"ro_ro.json", "rpr.json", "ru_ru.json", "ry_ua.json", "sah_sah.json",
"se_no.json", "sk_sk.json", "sl_si.json", "so_so.json", "sq_al.json",
"sr_cs.json", "sr_sp.json", "sv_se.json", "sxu.json", "szl.json",
"ta_in.json", "th_th.json", "tlh_aa.json", "tl_ph.json", "tok.json",
"tr_tr.json", "tt_ru.json", "tzo_mx.json", "uk_ua.json", "val_es.json",
"vec_it.json", "vi_vn.json", "vp_vl.json", "yi_de.json", "yo_ng.json",
"zh_cn.json", "zh_hk.json", "zh_tw.json", "zlm_arab.json"
]
if not os.path.exists(SOURCE_FILE):
print(f"Error: {SOURCE_FILE} not found in the current directory!")
print("Please make sure en_us.json is in the same directory as this script.")
return
backup_dir = Path("backup")
backup_dir.mkdir(exist_ok=True)
langs_dir = Path("langs")
langs_dir.mkdir(exist_ok=True)
copied_count = 0
backed_up_count = 0
print(f"Starting to copy {SOURCE_FILE} to {len(language_files)} language files...")
print("-" * 60)
for lang_file in language_files:
try:
lang_path = langs_dir / lang_file
if lang_path.exists():
backup_path = backup_dir / lang_file
shutil.copy2(lang_path, backup_path)
backed_up_count += 1
print(f"✓ Backed up existing {lang_file}")
shutil.copy2(SOURCE_FILE, lang_path)
copied_count += 1
print(f"✓ Copied to {lang_file}")
except Exception as e:
print(f"✗ Error copying to {lang_file}: {str(e)}")
print("-" * 60)
print(f"Operation completed!")
print(f"Files copied: {copied_count}/{len(language_files)}")
print(f"Files backed up: {backed_up_count}")
if backed_up_count > 0:
print(f"Backups saved in: {backup_dir.absolute()}")
def validate_json_file(filepath):
"""
Validates that a file is proper JSON format.
"""
try:
with open(filepath, 'r', encoding='utf-8') as f:
json.load(f)
return True
except json.JSONDecodeError as e:
print(f"JSON validation error in {filepath}: {str(e)}")
return False
except Exception as e:
print(f"Error reading {filepath}: {str(e)}")
return False
def main():
print("Minecraft Language File Copier")
print("=" * 40)
if os.path.exists("en_us.json"):
if not validate_json_file("en_us.json"):
print("Error: en_us.json is not a valid JSON file!")
return
response = input("\nThis will copy en_us.json to all other Minecraft language files.\n"
"Existing files will be backed up to a 'backup' folder.\n"
"Continue? (y/N): ")
if response.lower() in ['y', 'yes']:
copy_en_us_to_all_languages()
else:
print("Operation cancelled.")
if __name__ == "__main__":
main()