Skip to content

Localize the app into Chinese and translate post content on demand - #194

Closed
honfox wants to merge 1 commit into
clynamic:masterfrom
honfox:master
Closed

honfox wants to merge 1 commit into
clynamic:masterfrom
honfox:master

Conversation

@honfox

@honfox honfox commented Oct 20, 2026

Copy link
Copy Markdown

This adds Simplified Chinese as a UI language, plus on-demand translation of post descriptions and tags.

What changed:

  • lib/shared/data/trans.dart: an English to Chinese dictionary, plus two helpers. t() translates a plain string, tf() translates a template containing {placeholders}. Strings without a translation fall back to the original English text.
  • A language setting under Settings (follow system / English / Chinese), persisted with the existing settings backend.
  • User facing strings across the app are wrapped in t()/tf().
  • lib/shared/data/translate.dart: translates post descriptions and tags on demand. It uses the public Google Translate endpoint and falls back to MyMemory. Results are cached in memory. No new dependencies, dio was already used.
  • Fixed a UTF-8 BOM at the start of lib/app/widget/app.dart. Current Dart rejects it, so flutter build apk --release fails with "The non-ASCII space character U+FEFF can only be used in strings and comments".
  • Small dependency bumps in pubspec.lock, and analyzer excludes for the platform folders.

Most of the diff is the mechanical string wrapping. The actual logic changes are in the two new files, the settings page, and the post description and tag widgets.

Tested with flutter build apk --release, which succeeds.

Wrap all user-facing strings with t()/tf() and ship a built-in en->zh dictionary plus a settings language switch, so chinese users can use the app without patching. Also add on-demand translation for descriptions and tags, and strip a stray UTF-8 BOM from app.dart that breaks the release build on current dart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@honfox honfox closed this Oct 20, 2026
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