Skip to content

Commit

Permalink
FTBQ 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wulian233 committed Dec 7, 2024
1 parent f90fee7 commit 1f4d041
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 14 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/build_ftb_color_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build FTBQ Color Check and Upload

on:
push:
branches:
- main

jobs:
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install dependencies (Windows)
run: |
pip install pyinstaller
pip install -r ftbq_color_check/requirements.txt
- name: Build with PyInstaller (Windows)
run: |
python -m PyInstaller -F -n FTBQ-Color-Check-Windows ftbq_color_check/main.py
- name: Upload (Windows)
uses: actions/upload-artifact@v4
with:
path: dist/FTBQ-Color-Check-Windows.exe

build-macos:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install dependencies (macOS)
run: |
pip install pyinstaller
pip install -r ftbq_color_check/requirements.txt
- name: Build with PyInstaller (macOS)
run: |
python -m PyInstaller -F -n FTBQ-Color-Check-macOS ftbq_color_check/main.py
- name: Upload (macOS)
uses: actions/upload-artifact@v4
with:
name: FTBQ-Color-Check-macOS
path: dist/FTBQ-Color-Check-macOS

build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install dependencies (Linux)
run: |
pip install pyinstaller
pip install -r ftbq_color_check/requirements.txt
- name: Build with PyInstaller (Linux)
run: |
python -m PyInstaller -F -n FTBQ-Color-Check-Linux ftbq_color_check/main.py
- name: Upload (Linux)
uses: actions/upload-artifact@v4
with:
name: FTBQ-Color-Check-Linux
path: dist/FTBQ-Color-Check-Linux
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
**/*.exe
**/__pycache__
**/.idea
**/.vscode
**/build
**/dist
**/*.json
**/build
**/error_report.txt
**/*.exe
/*.spec
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## VM翻译辅助工具

[![Downloads](https://img.shields.io/github/downloads/VM-Chinese-translate-group/translate-tools/total?style=flat-square&logo=github)](https://github.com/VM-Chinese-translate-group/translate-tools/releases/)[![Last Version](https://img.shields.io/github/release/VM-Chinese-translate-group/translate-tools/all.svg?style=flat-square)](https://github.com/VM-Chinese-translate-group/translate-tools/releases/)[![License](https://img.shields.io/github/license/VM-Chinese-translate-group/translate-tools?style=flat-square)](LICENSE)

[![官网](https://img.shields.io/badge/官网-介绍-blue?style=flat-square)](https://vmct-cn.top/tools)

所有工具均完全免费且开源,一切为了社区发展。

# FTBQ 颜色字符检查

用于检查翻译后的语言文件中是否存在FTB任务&颜色字符后面的数字或字母丢失的问题。这会导致任务无法正常显示。

输入一个json路径,会检查颜色字符是否合法。

- 支持彩色提示信息。报错为红色,通过为绿色。
- 新增支持导出错误报告为txt。
- 可选是否在控制台打印详细信息
1. 开启会在控制台显示具体译文内容
2. 关闭会显示行号

开启详细信息:
```
[CNPack\kubejs\assets\ftbquest\lang\zh_cn.json] SyntaxError: Invalid character '。' after '&' at line 2705
"不用末影龙,直接制造&6龙息&。",
```

关闭详细信息:

```
[CNPack\kubejs\assets\ftbquest\lang\zh_cn.json] SyntaxError: Invalid character after '&' at line 2705
```

注:无论选择什么,最终保存报错的文件永远为详细版本。
- 支持检查单个或整个目录的json文件,更方便。
- 支持检查json本身格式问题。

# Paratranz译文同步工具

批量上传多个文件到Paratranz翻译平台,同时支持下载译文到本地。

使用相关功能需要有Paratranz的项目id和有对应权限用户的token,可在Paratranz个人主页查看。

## 下载

<a href="https://github.com/VM-Chinese-translate-group/translate-tools/releases">请在Release页面找到下载不同工具的对应页面</a>

## 构建

1. 安装 `Python` 环境

2. 构建(成品为对应系统的可执行文件)

FTBQ颜色字符检查:
```bash
pip install pyinstaller
pip install -r ftbq_color_check/requirements.txt
python -m PyInstaller -F -n FTBQ-Color-Check ftbq_color_check/main.py
```

Paratranz译文同步工具:
```bash
pip install pyinstaller
pip install -r paratranz_sync/requirements.txt
python -m PyInstaller paratranz_sync/main.spec
```

## 星标

支持开发者的最简单方式是点击页面顶部的星标(⭐)。

<p style="text-align: center;">
<a href="https://api.star-history.com/svg?repos=VM-Chinese-translate-group/translate-tools&Date">
<img alt="start" width=50% src="https://api.star-history.com/svg?repos=VM-Chinese-translate-group/translate-tools&Date"/>
</a>
</p>
25 changes: 17 additions & 8 deletions ftbq_color_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ def check_line_for_errors(
line: str, line_number: int, verbose: bool, relative_file_path: str
) -> list[str]:
errors = []
matches = re.finditer(r"&([^a-zA-Z1-9\s])", line)
matches = re.finditer(r"&([^a-v0-9\s])", line)
for match in matches:
error_message = f"SyntaxError: Invalid character '{match.group(1)}' after '&' at line {line_number}\n {line}"
error_message = f"SyntaxError{Fore.RESET}: {Fore.RED}Invalid character '{match.group(1)}' after '&' at line {line_number}\n {line}"
if verbose:
print(f"[{relative_file_path}] {Fore.RED}{error_message}")
else:
print(
f"[{relative_file_path}] {Fore.RED}SyntaxError: Invalid character after '&' at line {line_number}"
f"[{relative_file_path}] SyntaxError{Fore.RESET}: {Fore.RED}Invalid character after '&' at line {line_number}"
)
errors.append(f"[{relative_file_path}] {error_message}")
errors.append(f"[{relative_file_path}] {Fore.RED}{error_message}")
return errors


Expand Down Expand Up @@ -77,8 +77,17 @@ def save_errors_to_file(errors: list[str]) -> None:

def main() -> None:
print(
Fore.YELLOW
+ "FTB任务颜色字符合法检查 [版本 1.1 (2024)]\n作者:Wulian233(捂脸)\n"
Fore.BLUE
+ "FTB任务颜色字符合法检查 [版本 1.2 (2024)]\n作者:Wulian233(捂脸)\n\n"
+ Fore.RESET
+ """VM之禅:
一,即使翻译难易各异,译者应持己见自立。
二,即使遇到词句争议,组员务必同心共力。
三,即使译途坎坷跌宕,仍应坚守质量保障。
四,即使成果乏人褒奖,仍不计事后短长。
五,即使面临质疑声浪,仍要对正道守望。
六,即使译句纷乱无章,仍应看向前方、重塑文章。
"""
)
path = input("请输入 JSON 文件或目录路径:").strip()
verbose = input("是否显示详细错误信息?(y/n): ").strip().lower() == "y"
Expand All @@ -90,13 +99,13 @@ def main() -> None:
path, os.path.relpath(path, start=os.path.dirname(path)), verbose
)
else:
print(Fore.RED + "输入的路径无效,请输入有效的 JSON 文件路径或目录。")
print(f"❌ {Fore.RED}输入的路径无效,请输入有效的 JSON 文件路径或目录。")
return

if errors:
save_errors_to_file(errors)
else:
print(Fore.GREEN + "文件检查通过,没有发现错误。")
print(f"✅ {Fore.GREEN}文件检查通过,没有发现错误。")

input("按任意键(关机键除外)退出...")

Expand Down
9 changes: 5 additions & 4 deletions paratranz_sync/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import asyncio
import json
import sys
import re
import os
from tkinter import filedialog, Tk, END, messagebox
from tkinter.ttk import Label, Entry, Button, Checkbutton, Progressbar
import re
import sys
from tkinter import END, Tk, filedialog, messagebox
from tkinter.ttk import Button, Checkbutton, Entry, Label, Progressbar

import aiohttp
import sv_ttk
Expand Down Expand Up @@ -268,6 +268,7 @@ def main() -> None:
ParatranzUploader(root)

import base64

from icon import img

with open("window_icon.ico", "wb+") as icon:
Expand Down

0 comments on commit 1f4d041

Please sign in to comment.