Skip to content

Interface in Chinese and English, following the account, the device or the system - #5

Merged
songtianlun merged 6 commits into
mainfrom
ccr-ed0fcefa-udrvvj
Nov 7, 2026
Merged

songtianlun merged 6 commits into
mainfrom
ccr-ed0fcefa-udrvvj

Conversation

@songtianlun

Copy link
Copy Markdown
Member

Summary

The app now speaks 简体中文 and English, and the account's language is wired to the server's new language API (ivynote#36, guide §界面语言).

Which language is used

  1. Signed in to a synced library and User.language is set: the account's language, the same on every device.
  2. Otherwise, the choice made on this device, remembered across launches and sign-outs.
  3. Otherwise, the system: the first supported language in its list, English if none. The app follows system changes, including Android 13's per-app language.

Server integration

  • POST /auth/register sends language with the language in use at sign-up.
  • Choosing a language while signed in sends PATCH /me {language}. "Follow the system" clears it ("").
  • A change made offline is kept as pending, wins over the server's older value, and is sent on the next open or return to the foreground.
  • Every request carries Accept-Language.

Implementation

  • core/…/Strings.kt is one Strings interface with ZhStrings and EnStrings, so a missing translation does not compile. Core messages (errors, validation, shelf labels, regions, media filters) read L10n.s.
  • The UI reads LocalStrings, a static composition local, so a language change recomposes everything below it.
  • LanguageSettings (core) resolves the language and keeps the pending changes. OpenLibrary feeds it User.language and pushes pending changes through SessionStore.pushLanguage.
  • A language picker labelled 语言 · Language sits in three places: the library menu, the libraries list and the account sheet.
  • Dates and relative times follow the interface language. The sync node is still preselected by the system's region.
  • The editor page gets ivy.setLanguage, which localizes its placeholder and formatting words. It also sets <html lang>, which the shared editor follows. The bundle is rebuilt from ivynote main.

Testing

  • ./gradlew :core:test: new LanguageTest covering resolution, persistence, account priority, pending and pushed changes, and English plurals. New ApiClientTest cases cover the register body, PATCH /me and Accept-Language.
  • CI is green on the branch: core tests, debug and release APKs, app unit tests and lint.
  • Not tested on a device.

Generated by Claude Code

Every string the app shows comes from one Strings interface in core with a
Chinese and an English implementation, so a missing translation does not
compile. LanguageSettings picks the language: the signed-in account's
choice, then the choice made on this device (remembered), then the system's
language (first supported one, English otherwise). A new account starts with
the language in use when it registered. A picker sits in the library menu,
the libraries list and the account sheet.

Until the server stores the account's language, it is kept on this device
per account; IvyApp marks where it will be sent and read. Requests carry
Accept-Language. Dates and relative times follow the language; the sync
node is still preselected by the system's region. The editor page gets
setLanguage for its placeholder and formatting words.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ7eDkNbqLj8z7BEXeW8wW
User.language (from /me and sign-in) comes first when a synced library is
open; "" means not set and falls back to this device's choice, then the
system. Choosing in settings while signed in sends PATCH /me {language}
("follow the system" clears it); a change made offline is kept as pending,
wins over the server's older value and is sent on the next open or return
to the foreground. Registration sends the language in use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ7eDkNbqLj8z7BEXeW8wW
…nguage callback

The shared editor now follows <html lang>, which setLanguage sets, so its
link, task and completion words follow the interface too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ7eDkNbqLj8z7BEXeW8wW
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ7eDkNbqLj8z7BEXeW8wW
The in-app updater merged from main showed Chinese only; its dialog, about
sheet, toasts and installer messages now come from Strings in both languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZ7eDkNbqLj8z7BEXeW8wW
@songtianlun
songtianlun merged commit c7d303d into main Nov 7, 2026
2 checks passed
@songtianlun
songtianlun deleted the ccr-ed0fcefa-udrvvj branch November 7, 2026 02:56
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.

2 participants