71 lines
3.0 KiB
Python
71 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""审计三个 jar 的语言文件覆盖情况:
|
|
1) 资源(br blockstates / models.item)有、但 lang 缺 key 的(游戏内显示原始 key)
|
|
2) en_us 有、zh_cn 缺(未汉化)
|
|
"""
|
|
import zipfile, json, io, sys, os
|
|
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
|
|
BASE = r'e:\MCStudioDownload\work\3027246179@qq.com\Cpp\AddOn\0aaaa4f2f16c46e8964025a5ab0ecc02\_sa_hanhua_out'
|
|
JARS = ['sa_essentials-forge-1.20.1-1.0.0.jar',
|
|
'sa_lib-forge-1.20.1-1.0.1.jar',
|
|
'sa_decor-forge-1.20.1-1.0.3.jar']
|
|
|
|
for jn in JARS:
|
|
p = os.path.join(BASE, jn)
|
|
if not os.path.exists(p):
|
|
continue
|
|
z = zipfile.ZipFile(p)
|
|
names = z.namelist()
|
|
|
|
# 命名空间
|
|
ass_roots = sorted({n.split('/')[1] for n in names if n.startswith('assets/') and len(n.split('/')) > 2})
|
|
print('=' * 70)
|
|
print('JAR:', jn, ' namespaces:', ass_roots)
|
|
|
|
for ns in ass_roots:
|
|
prefix = 'assets/%s/' % ns
|
|
langfiles = {}
|
|
for n in names:
|
|
if n.startswith(prefix + 'lang/') and n.endswith('.json'):
|
|
loc = os.path.basename(n)[:-5]
|
|
langfiles[loc] = json.loads(z.read(n).decode('utf-8-sig'))
|
|
|
|
bs = sorted(os.path.basename(n)[:-5] for n in names
|
|
if n.startswith(prefix + 'blockstates/') and n.endswith('.json'))
|
|
im = sorted(os.path.basename(n)[:-5] for n in names
|
|
if n.startswith(prefix + 'models/item/') and n.endswith('.json'))
|
|
|
|
en = langfiles.get('en_us', {})
|
|
zh = langfiles.get('zh_cn', {})
|
|
|
|
print('-' * 60)
|
|
print('[%s] lang=%s blocks=%d item_models=%d' % (ns, sorted(langfiles), len(bs), len(im)))
|
|
|
|
miss_en = [b for b in bs if ('block.%s.%s' % (ns, b)) not in en and ('item.%s.%s' % (ns, b)) not in en]
|
|
miss_zh = [b for b in bs if ('block.%s.%s' % (ns, b)) not in zh and ('item.%s.%s' % (ns, b)) not in zh]
|
|
miss_i_en = [i for i in im if ('item.%s.%s' % (ns, i)) not in en and ('block.%s.%s' % (ns, i)) not in en]
|
|
miss_i_zh = [i for i in im if ('item.%s.%s' % (ns, i)) not in zh and ('block.%s.%s' % (ns, i)) not in zh]
|
|
|
|
def show(t, l):
|
|
if l:
|
|
print(' %s (%d): %s' % (t, len(l), ', '.join(l[:60])))
|
|
else:
|
|
print(' %s (0)' % t)
|
|
|
|
show('方块 资源有/zh_cn缺', miss_zh)
|
|
show('方块 资源有/en_us缺', miss_en)
|
|
show('物品 资源有/zh_cn缺', miss_i_zh)
|
|
show('物品 资源有/en_us缺', miss_i_en)
|
|
|
|
# en 有 zh 缺
|
|
if en and zh:
|
|
only_en = sorted(k for k in en if k not in zh)
|
|
if only_en:
|
|
print(' en_us 有 / zh_cn 缺 (%d): %s' % (len(only_en), ', '.join(only_en[:60])))
|
|
# zh 是英文原文(未翻译)的 key
|
|
same = sorted(k for k in zh if k in en and zh[k] == en[k] and any(c.isalpha() for c in zh[k]))
|
|
if same:
|
|
print(' zh_cn 内容仍是英文 (%d): %s' % (len(same), ', '.join(same[:60])))
|
|
z.close() |