Skip to content
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

可以加一个功能吗,按照顺序翻译不同的文件夹,这个文件夹翻译完了继续翻译另一个文件夹,以及可以加一个翻译完成的提示吗 #126

Open
wycstc353 opened this issue Jul 30, 2024 · 1 comment

Comments

@wycstc353
Copy link

可以加一个功能吗,按照顺序翻译不同的文件夹,这个文件夹翻译完了继续翻译另一个文件夹,以及可以加一个翻译完成的提示吗

就是可能一个游戏快翻译完了,然后人又要出去一段时间,不想浪费翻译时间,所以想弄个设定,可以在当前游戏翻译完后翻译另一个游戏。
还有翻译完成可以加个提示音或者弹窗提示吗?

@PiDanShouRouZhouXD
Copy link
Collaborator

import os
import sys

from command import BulletMenu
from GalTransl import (
    AUTHOR,
    CONFIG_FILENAME,
    CONTRIBUTORS,
    GALTRANSL_VERSION,
    PROGRAM_SPLASH,
    TRANSLATOR_SUPPORTED,
)
from GalTransl.__main__ import worker

def get_project_info(project_path):
    if project_path.endswith(".yaml"):
        config_file_name = os.path.basename(project_path)
        project_dir = os.path.dirname(project_path)
    else:
        config_file_name = CONFIG_FILENAME
        project_dir = project_path

    return project_dir, config_file_name

def get_projects():
    project_list = []
    print("请输入项目路径,输入完成按回车后输入下一个,输入 'done' 结束输入:")
    while True:
        project_path = input().strip('"')
        if project_path.lower() == 'done':
            break
        if project_path:
            project_list.append(project_path)
    return project_list

def select_translator():
    os.system("")  # 解决cmd的ANSI转义bug
    print("请选择翻译器:")
    translator_menu = BulletMenu("翻译器选项:", TRANSLATOR_SUPPORTED)
    return translator_menu.run(0)

def main():
    print(PROGRAM_SPLASH)
    print(f"Ver: {GALTRANSL_VERSION}")
    print(f"Author: {AUTHOR}")
    print(f"Contributors: {CONTRIBUTORS}\n")

    translator = select_translator()  # 选择翻译器
    project_paths = get_projects()  # 获取项目路径列表

    for path in project_paths:
        project_dir, config_file_name = get_project_info(path)
        print(f"Processing project at: {project_dir}")

        try:
            worker(project_dir, config_file_name, translator, show_banner=False)
            print(f"Project at {project_dir} has been translated successfully.")
        except KeyboardInterrupt:
            print("\nGoodbye.")
            sys.exit(0)

if __name__ == "__main__":
    main()

将这个python脚本放置于项目根目录中可以实现你需要的功能1。

弹窗提示不太可能,要等UI写好了。后续版本会有一个server酱推送完成信息的插件。
text_message_serverchan.zip
你也可以先用着。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants