Files
lnxgit/scripts/wsl_patch_bootstrap_text.sh
LnxGit a8ab8e7906 分支地图:当前分支选择框、按分支配色与颜色图例;原生提示改中文
分支选择框(图谱页顶部)
* 「全部引用」+ 各本地分支(当前分支标注「(当前)」)+ 末项「+ 新建分支…」
* 选中某个分支就只看它的历史(走 gitcore 的 branch 过滤),留空则铺开全部引用
* 选「新建分支…」弹输入框,创建并切换后回到全部引用视图;ComboBox 不支持
  空选项,所以先把 currentIndex 还原再弹窗

按分支配色 + 颜色标识
* 颜色从「按轨道」改为「按分支名」分配:同一分支的提交与连线同色;中间的
  提交没有引用,就继承第一个引用它的子提交所属的分支。
* 新增 _branches_by_sha():只取分支引用。一个提交同时挂着分支和标签时
  (main 上打了 v1.0),标签名不该顶替分支名 —— 否则图例会显示 v1.0 而没有 main。
* 接口返回 mapLegend(分支名 → 颜色),图谱页顶部渲染成一行色点 + 名字,
  可横向滚动。

原生提示改中文
* p4a 的 Java 模板里硬编码了返回键提示 "Click again to close the app",
  新增 scripts/wsl_patch_bootstrap_text.sh 在构建时替换为中文;中文写成
  \uXXXX 转义,绕开 javac 的 -encoding 差异。
* 该补丁放在 wsl_build.sh 的 root 阶段执行 —— p4a 源码不一定属于 builder。

测试
* graph_test 新增三条断言:同一分支颜色必须一致、图例与提交实际颜色必须
  对得上、按分支过滤时不能混进其它分支的提交。

已验证:分支选择框与图例(● hotfix ● main ● feature)在模拟器截图确认;
退出提示已变成中文「再按一次返回键退出」。
2026-09-23 03:20:49 +08:00

48 lines
1.5 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 把 p4a 的 qt bootstrap 里硬编码的英文提示换成中文。
#
# 这些文案在 python-for-android 的 Java 模板里(PythonActivity.java 等),
# 应用界面全是中文,只有返回键提示还是 "Click again to close the app"。
#
# 中文一律写成 \uXXXX 转义:Java 编译器对源文件编码敏感,转义可以绕开
# gradle/javac 的 -encoding 差异,任何环境下都不会乱码。
set -euo pipefail
WORK="${WORK:-/opt/lnxgit-android}"
P4A_SRC="${LNXGIT_P4A_SOURCE:-$WORK/p4a-src}"
BOOTSTRAP="${BOOTSTRAP:-$P4A_SRC/pythonforandroid/bootstraps/qt/build/src/main/java}"
[ -d "$BOOTSTRAP" ] || { echo "找不到 bootstrap Java 目录: $BOOTSTRAP" >&2; exit 1; }
python3 - "$BOOTSTRAP" <<'PY'
import sys
from pathlib import Path
# 英文原文 -> 中文(\uXXXX 转义)
REPLACEMENTS = {
'"Click again to close the app"': '"\\u518d\\u6309\\u4e00\\u6b21\\u8fd4\\u56de\\u952e\\u9000\\u51fa"',
}
root = Path(sys.argv[1])
total_files = total_hits = 0
for path in sorted(root.rglob("*.java")):
try:
text = path.read_text(encoding="utf-8")
except OSError:
continue
hits = 0
for old, new in REPLACEMENTS.items():
if old in text:
text = text.replace(old, new)
hits += 1
if not hits:
continue
path.write_text(text, encoding="utf-8")
total_files += 1
total_hits += hits
print(f" 改写 {path.name}({hits} 处)")
print(f"==> 共处理 {total_files} 个文件、{total_hits} 处文案")
PY