#!/usr/bin/env python3 """检查翻译缓存中的结果是否包含占位符""" import json import os translations_dir = "cache/translations" all_translations = {} # 遍历缓存文件 for root, dirs, files in os.walk(translations_dir): for f in files: if f.endswith('.json'): path = os.path.join(root, f) with open(path, 'r') as fp: cache = json.load(fp) if 'translations' in cache: for k, v in cache['translations'].items(): all_translations[k] = {'trans': v, 'file': path} # 检查 p_00006 (已知有占位符的 item) target_id = 'p_00006' if target_id in all_translations: data = all_translations[target_id] print(f"=== CACHED TRANSLATION FOR {target_id} ===") print(f"Cache file: {data['file']}") print(f"Translation: {data['trans']}") print(f"Contains φ: {'φ' in data['trans']}") else: print(f"{target_id} not found in cache") # 统计有多少缓存翻译包含 φ with_phi = sum(1 for v in all_translations.values() if 'φ' in v['trans']) total = len(all_translations) print(f"\n=== CACHE STATS ===") print(f"Total cached translations: {total}") print(f"Translations with φ: {with_phi}") print(f"Translations without φ: {total - with_phi}")