Skip to content

localization: translate code comments to English#15

Merged
hawkff merged 2 commits into
mainfrom
localization/english-comments
Jun 15, 2026
Merged

localization: translate code comments to English#15
hawkff merged 2 commits into
mainfrom
localization/english-comments

Conversation

@hawkff

@hawkff hawkff commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Translates all non-English (mostly Chinese) code comments across the app and libcore
source to English, for a single-language, maintainable codebase.

Scope and safety

  • Comments only. No code, identifiers, logic, formatting, or whitespace changed.
  • String literals are NOT touched — verified. In particular, three functional/UI
    literals were deliberately preserved (they are not comments):
    • ProfileManager.kt "cn:中国" — country-match logic data.
    • NaiveSettingsActivity.kt "喵要打开隐藏功能" / "喵要关闭隐藏功能" — magic
      easter-egg trigger strings (translating would break the feature).
    • WebDAVSettingsActivity.kt "请稍后再试" — existing hardcoded Snackbar string.
      (Left as-is to keep this branch comments-only; could be moved to a string resource
      in a separate UI PR.)
  • Translation resource files under res/values-zh-*, values-ja, values-ko were
    not touched — those are real UI translations for users and must stay.
  • Vendored libcore/gomobile was excluded.

Files

28 source files (.kt / .java / .go), comment text only. Diff is ~1:1 line
replacement (+146/−144) — almost entirely full-line or trailing-comment swaps.

Verification (AWS Linux builder)

  • After translation, only the 4 protected string literals remain as CJK in source
    (confirmed by scan) — every comment was translated.
  • Native core rebuilt (libcore Go comment changes included) and
    ./gradlew app:assembleOssDebug — BUILD SUCCESSFUL.
  • Local CodeRabbit review: addressed one note (clarified two webview lock-file path
    comments to reflect the actual defensive both-paths intent).

hawkff added 2 commits June 15, 2026 18:22
Translate all non-English (mostly Chinese) code comments across app and libcore
source to English. Comments only — no code, identifiers, logic, formatting, or
string literals changed.

Deliberately preserved (functional/UI string literals, not comments):
- ProfileManager.kt "cn:中国" (country-match logic data)
- NaiveSettingsActivity.kt "喵要打开隐藏功能"/"喵要关闭隐藏功能" (easter-egg triggers)
- WebDAVSettingsActivity.kt "请稍后再试" (existing hardcoded Snackbar string)
Reword the two translated comments to reflect the actual defensive intent
(both path variants are checked because suffix presence is device-dependent)
rather than implying contradictory absolute Android behavior.
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hawkff, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 6 hours, 29 minutes, and 8 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: abad34f9-0cb7-40f3-ab32-49841be527f9

📥 Commits

Reviewing files that changed from the base of the PR and between 11d7cb6 and 76dc0d8.

📒 Files selected for processing (28)
  • app/src/main/java/io/nekohasekai/sagernet/database/DataStore.kt
  • app/src/main/java/io/nekohasekai/sagernet/database/ProfileManager.kt
  • app/src/main/java/io/nekohasekai/sagernet/fmt/ConfigBuilder.kt
  • app/src/main/java/io/nekohasekai/sagernet/fmt/snell/SnellFmt.kt
  • app/src/main/java/io/nekohasekai/sagernet/fmt/trojan_go/TrojanGoBean.java
  • app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/StandardV2RayBean.java
  • app/src/main/java/io/nekohasekai/sagernet/fmt/v2ray/V2RayFmt.kt
  • app/src/main/java/io/nekohasekai/sagernet/group/RawUpdater.kt
  • app/src/main/java/io/nekohasekai/sagernet/ktx/Formats.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/BackupFragment.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/GroupSettingsActivity.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/LogcatFragment.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/MainActivity.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/RouteFragment.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/ScannerActivity.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/SettingsPreferenceFragment.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/WebDAVSettingsActivity.kt
  • app/src/main/java/io/nekohasekai/sagernet/ui/WebviewFragment.kt
  • app/src/main/java/moe/matsuri/nb4a/SingBoxOptions.java
  • app/src/main/java/moe/matsuri/nb4a/SingBoxOptionsUtil.kt
  • app/src/main/java/moe/matsuri/nb4a/net/LocalResolverImpl.kt
  • app/src/main/java/moe/matsuri/nb4a/utils/JavaUtil.java
  • app/src/main/java/moe/matsuri/nb4a/utils/Util.kt
  • libcore/assets_android.go
  • libcore/dns_box.go
  • libcore/http.go
  • libcore/platform_box.go

Comment @coderabbitai help to get the list of available commands and usage tips.

@hawkff hawkff marked this pull request as ready for review June 15, 2026 22:30
@hawkff

hawkff commented Jun 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

This branch translates code comments (Chinese -> English) only. Please verify: no code/logic/identifier/string-literal changes; the 3 protected functional literals (ProfileManager 'cn:中国', NaiveSettingsActivity easter-egg triggers, WebDAVSettingsActivity Snackbar) are preserved; and res/values-* translation files are untouched. Build verified (core + assembleOssDebug).

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch PR details and file list
gh pr view 15 --repo hawkff/NekoBoxForAndroid --json title,body,files | jq .

echo "=== FILES CHANGED ==="
gh pr diff 15 --repo hawkff/NekoBoxForAndroid --name-only

Length of output: 8210


🏁 Script executed:

#!/bin/bash
# Get the full diff
gh pr diff 15 --repo hawkff/NekoBoxForAndroid 2>&1 | head -3000

Length of output: 47616


🏁 Script executed:

#!/bin/bash
# Check for the 3 protected literals in the changed files
echo "=== Checking protected literals ==="

echo "--- cn:中国 in ProfileManager ---"
rg "cn:中国" --type=kotlin -n -C2

echo "--- Easter egg triggers in NaiveSettingsActivity ---"
rg "喵要打开隐藏功能|喵要关闭隐藏功能" --type=kotlin -n -C2

echo "--- WebDAVSettingsActivity Snackbar ---"
rg "请稍后再试" --type=kotlin -n -C2

echo "=== Check for any remaining CJK in source files (non-res, non-vendor) ==="
rg -n "[\x{4e00}-\x{9fff}]" --type=kotlin --type=java --type=go \
   --glob '!**/res/**' --glob '!**/libcore/gomobile/**' \
   -l

echo "=== Check res/values-zh* and values-ja, values-ko are untouched (should exist) ==="
fd . --type=d --glob 'values-zh*' app/src/main/res/
fd . --type=d --glob 'values-ja' app/src/main/res/
fd . --type=d --glob 'values-ko' app/src/main/res/

Length of output: 4310


🏁 Script executed:

#!/bin/bash
# Get the full diff - second half
gh pr diff 15 --repo hawkff/NekoBoxForAndroid 2>&1 | tail -3000

Length of output: 47630


🏁 Script executed:

#!/bin/bash
# Check for any changes to res/values-* files in this PR
gh pr diff 15 --repo hawkff/NekoBoxForAndroid --name-only | grep "res/values"

echo "=== Check for any changes to string literals (non-comment lines with CJK in diff) ==="
gh pr diff 15 --repo hawkff/NekoBoxForAndroid 2>&1 | grep "^[+-]" | grep -v "^---\|^+++" | grep -P "[\x{4e00}-\x{9fff}]"

echo "=== Count added/removed lines ==="
gh pr diff 15 --repo hawkff/NekoBoxForAndroid 2>&1 | grep "^+" | grep -v "^+++" | wc -l
gh pr diff 15 --repo hawkff/NekoBoxForAndroid 2>&1 | grep "^-" | grep -v "^---" | wc -l

echo "=== Check for any non-comment line changes (lines changed that don't start with // or * or #) ==="
gh pr diff 15 --repo hawkff/NekoBoxForAndroid 2>&1 | grep "^[+-]" | grep -v "^---\|^+++" | grep -v "^\(+\|-\)[[:space:]]*//" | grep -v "^\(+\|-\)[[:space:]]*\*" | grep -v "^\(+\|-\)[[:space:]]*#" | head -100

Length of output: 4864



@hawkff: Full review complete. Here are the findings across all 28 changed files.


✅ Verification Summary

1 — Comments only, no code/logic/identifier/string-literal changes

Pass. Every modified line was inspected. Lines that contain non-comment tokens (trailing inline comments) were individually checked — in each case the code portion before // is byte-for-byte identical between the - and + lines; only the trailing comment text changed. Examples confirmed clean:

File Code token (unchanged) Comment changed
DataStore.kt { "0" } // 默认为0…// defaults to 0…
StandardV2RayBean.java input.getByteBuffer().position(); // 当前位置// current position
WebDAVSettingsActivity.kt code != 405) { // 405 表示…// 405 means…
BackupFragment.kt isWebDAVBackup = false // 确保…// ensure…
RouteFragment.kt -2L -> R.color.color_route_block // 屏蔽:红色// block: red
JavaUtil.java pathSet.add(dataPath + webViewDir + lockFile); //默认未…// path variant without…

No identifiers, logic branches, data values, whitespace structure, or string literals were altered.

2 — Three protected functional literals preserved

Pass.

Literal File Status
"cn:中国" ProfileManager.kt line 207 ✅ Present and untouched
"喵要打开隐藏功能" NaiveSettingsActivity.kt line 61 ✅ Present and untouched
"喵要关闭隐藏功能" NaiveSettingsActivity.kt line 63 ✅ Present and untouched
"请稍后再试" WebDAVSettingsActivity.kt line 114 ✅ Present and untouched

NaiveSettingsActivity.kt is not in the changed-files list — correct, since those strings live in code, not comments.

Post-PR CJK scan confirms only these 3 files retain CJK characters in source, exactly matching the 4 protected literals. Zero translated comments remain in Chinese.

3 — res/values-* translation files untouched

Pass. The changed-file list contains no res/values-* path. All locale resource files (values-zh-rCN, values-zh-rTW, values-ja, values-ko, etc.) are absent from the diff entirely.

4 — Translation quality

All 28 files reviewed. Translations are accurate and idiomatic. A few notes:

  • // 重名了喵// name collision, nya — charming; preserves the project's cat-theme intent. ✅
  • TrojanGoBean.java Javadoc blocks: multi-sentence Chinese technical prose translated accurately, maintaining meaning (e.g. RFC Host header warning, Shadowsocks format description). ✅
  • SingBoxOptions.java comment // sing-box Options 生成器已经坏了,以下是从 husi 抄的// the sing-box Options generator is already broken; the following is copied from husi — candid and accurate. ✅
  • libcore/*.go Go comments all correctly translated. ✅
  • WebDAVSettingsActivity.kt note: "请稍后再试" Snackbar hardcoded string is intentionally left as-is per PR scope. A follow-up to move it to a string resource (R.string.*) would be worth tracking separately.

5 — Line count

+144 / −142 — essentially 1:1 replacement as stated (~146/−144 in PR description accounts for minor Javadoc block reflow in TrojanGoBean.java where two short Chinese lines expanded to slightly longer English prose).


Overall: the PR meets all stated criteria. No issues found. Safe to merge.

@hawkff hawkff merged commit 5889145 into main Jun 15, 2026
4 checks passed
@hawkff hawkff deleted the localization/english-comments branch June 15, 2026 22:34
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

Successfully merging this pull request may close these issues.

1 participant