Skip to content

chore: chinese language added by @OrangePig007 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions xcoder/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def question(message: str) -> bool:


if __name__ == "__main__":
console = Console()
console.ask_integer("Please, type any integer")
Console.ask_integer("Please, type any integer")

for i in range(1000):
console.progress_bar("Test progress bar", i, 1000)
Console.progress_bar("Test progress bar", i, 1000)
2 changes: 1 addition & 1 deletion xcoder/languages/en-EU.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"crt_workspace": "Creating workspace directories...",
"verifying": "Verifying installation...",
"installed": "%s was successfully installed!",
"update_done": "The update was downloaded successfully! Please move all files from directory%s to script directory",
"update_done": "The update was downloaded successfully! Please move all files from directory %s to script directory",
"not_installed": "%s wasn't installed!",
"clear_qu": "Are you sure you want to clear the dirs?",
"done": "Completed in %.2f seconds!",
Expand Down
4 changes: 2 additions & 2 deletions xcoder/languages/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"xcoder_header": "XCoder | Версия: %s | От: Vorono4ka",
"detected_os": "Обнаружена система %s.",
"installing": "Установка необходимых модулей...",
"update_downloading": "Скачивание обновления...",
"update_downloading": "Загрузка обновления...",
"crt_workspace": "Создаются рабочие папки...",
"verifying": "Проверка установки...",
"installed": "%s успешно установлен!",
"update_done": "Обновление успешно скачалось! Пожалуйста, переместите все файлы из каталога%s в каталог скрипта",
"update_done": "Обновление успешно загружено! Пожалуйста, переместите все файлы из каталога %s в каталог скрипта",
"not_installed": "%s не установлен!",
"clear_qu": "Вы действительно хотите очистить папки?",
"done": "Выполнено за %.2f секунд!",
Expand Down
94 changes: 94 additions & 0 deletions xcoder/languages/zh-CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"name": "简体中文",
"xcoder_header": "XCoder | 版本: %s | Vorono4ka制作 | OrangePig汉化",
"detected_os": "检测到 %s 操作系统。",
"installing": "正在安装所需模块...",
"update_downloading": "更新下载中...",
"crt_workspace": "正在创建工作空间目录...",
"verifying": "正在验证安装...",
"installed": "%s 安装成功!",
"update_done": "更新下载成功!请将所有文件从目录%s移动到脚本目录",
"not_installed": "%s 未安装!",
"clear_qu": "确定要清空目录吗?",
"done": "已完成,用时 %.2f 秒!",
"done_qu": "完成?",
"choice": "你的选择(输入数字后回车):",
"to_continue": "按回车键继续...",
"experimental": "实验性功能",

"sc_label": "SC 文件(一般为 UI 或特效贴图)",
"decode_sc": "SC 转 PNG",
"encode_sc": "PNG 转 SC",
"decode_by_parts": "SC 转 精灵图",
"encode_by_parts": "精灵图 转 SC",
"overwrite_by_parts": "精灵图 转 SC(覆盖)",
"decode_sc_description": "将 SC 转换为一整张大的 PNG",
"encode_sc_description": "将一整张大的 PNG 转换为 SC",
"decode_by_parts_description": "将 SC 转换为 PNG 并按照成分切割",
"encode_by_parts_description": "将一张张独立的精灵图组合好并转换为 SC",
"overwrite_by_parts_description": "同上,但会 \"覆盖\" 文件夹",

"csv_label": "CSV 文件(一般为各种数据)",
"decompress_csv": "解压 CSV",
"compress_csv": "压缩 CSV",
"decompress_csv_description": "解压电子表格文件",
"compress_csv_description": "压缩电子表格文件",

"ktx_label": "KTX 文件(一般为模型贴图)",
"ktx_from_png_label": "PNG 转 KTX",
"png_from_ktx_label": "KTX 转 PNG",
"ktx_from_png_description": "将 PNG 转换为 KTX",
"png_from_ktx_description": "将 KTX 转换为 PNG",

"other_features_label": "其他选项",
"check_update": "检查更新",
"reinit": "重新初始化",
"change_language": "切换语言",
"clear_directories": "清空工作空间目录",
"toggle_update_auto_checking": "切换自动检查更新",
"exit": "退出",
"version": "当前版本:%s",
"reinit_description": "如果出现问题,请重新初始化",
"change_lang_description": "当前语言:%s",
"clean_dirs_description": "清空输入和输出目录",

"not_latest": "安装的不是最新版本",
"collecting_inf": "文件:%s。正在收集信息...",
"about_sc": "关于纹理。文件名:%s (%d),像素类型:%d,尺寸:%sx%s",
"decompression_error": "解压时出错!尝试直接解码...",
"skip_not_installed": "%s 未安装!请重新初始化",
"detected_comp": "检测到 %s 压缩",
"unknown_pixel_type": "未知像素类型:%s",
"crt_pic": "正在创建图片...",
"join_pic": "正在合并图片...",
"png_save": "正在保存为 png...",
"saved": "保存完成!",
"xcod_not_found": "文件 '%s.xcod' 不存在!",
"illegal_size": "非法图片尺寸!预期为 %sx%s,但得到的是 %sx%s",
"resize_qu": "是否需要调整图片尺寸?",
"resizing": "正在调整大小...",
"split_pic": "正在切割图片...",
"writing_pic": "正在写入像素...",
"compressing_with": "使用 %s 压缩纹理...",
"compression_error": "压缩失败",
"compression_done": "压缩完成!",
"dir_empty": "目录 '%s' 为空!",
"not_found": "文件 '%s' 未找到!",
"cut_sprites_process": "正在裁剪精灵图... (%d/%d)",
"place_sprites_process": "正在放置精灵图... (%d/%d)",
"not_implemented": "此功能将在未来更新中添加。\n你可以在此处关注 XCoder 更新:{repo_url}",
"error": "错误!(%s.%s: %s)",
"e1sc1": "覆盖 SC 精灵图",
"cgl": "更新日志:\n%s",
"upd_av": "\n有可用更新!\n版本:%s\n",
"upd_qu": "你要更新吗?",
"upd": "正在更新...",
"upd_ck": "正在检查更新...",
"bkp": "正在备份当前版本...",
"stp": "正在安装...",
"margin_qu": "考虑边缘空白吗?",
"enabled": "已启用",
"disabled": "已禁用",

"install_to_unlock": "安装 '%s' 以解锁更多功能!"
}
2 changes: 0 additions & 2 deletions xcoder/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ def load(self, language: str):
def change(self):
language_files = os.listdir(_LOCALES_DIRECTORY)

print("Select Language\nВыберите язык\nВиберіть Мову\n")

for file_index, language_file in enumerate(language_files):
language_path = _LOCALES_DIRECTORY / language_file
language_name = json.load(open(language_path, encoding="utf-8"))["name"]
Expand Down
23 changes: 13 additions & 10 deletions xcoder/pvr_tex_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,29 @@ def can_use_pvr_tex_tool() -> bool:
return _cli_path is not None


# noinspection PyTypeChecker
def get_image_from_ktx_data(data: bytes) -> Image.Image:
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".ktx")
try:
with tempfile.NamedTemporaryFile(delete=False, suffix=".ktx") as tmp:
tmp.write(data)
finally:
tmp.close()

image = get_image_from_ktx(Path(tmp.name))
os.remove(tmp.name)
try:
image = get_image_from_ktx(Path(tmp.name))
finally:
os.remove(tmp.name)

return image


# noinspection PyTypeChecker
def get_image_from_ktx(filepath: Path) -> Image.Image:
png_filepath = convert_ktx_to_png(filepath)
image_open = Image.open(png_filepath)
image = image_open.copy()
image_open.close()
os.remove(png_filepath)
return image

try:
return image_open.copy()
finally:
image_open.close()
os.remove(png_filepath)


def convert_ktx_to_png(filepath: Path, output_folder: Path | None = None) -> Path:
Expand Down