Repository navigation
feat(i18n): add Simplified Chinese to the app and the bundled web UI - #4
Closed
naturalwill wants to merge 5 commits into
Closed
naturalwill wants to merge 5 commits into
naturalwill wants to merge 5 commits into
Conversation
The native screens wrote their labels as English literals inside Kotlin, so there was no way to offer the app in another language. Move every label the app shows into the string resources and add a values-zh-rCN set carrying the Simplified Chinese wording. Android 13 and later list the app's languages in the system settings; locales_config.xml names English and zh-CN. On earlier releases the app follows the system language through the resource qualifiers, as it does for every other Android app.
Every user-visible string in the Compose screens, the widgets, the shortcuts and the banners now comes from res/values/strings.xml, so the resource set can be translated. The English wording is unchanged; only where the text is looked up has moved. A button's callback is a plain lambda, in which a resource cannot be read, so the confirmations take their title, message and action from the composable scope instead. The WebView is told which language the app runs in, so that its half of the screen follows the same choice as the native half.
The web UI writes its labels as plain English literals, which upstream keeps editing. Rather than rewriting them, the DOM helper passes each label through a lookup that falls back to the English word, so a missing entry can never break the page and upstream's wording stays the source of truth. Adds a 400-entry zh-CN dictionary covering the panel, the floor plan editor, the connections and the AI Access window, together with the few places that write text straight to the DOM instead of through the helper. The phone's language reaches the page through window.__HOUSE_BOOT__.locale, and the page sets its document language to match.
Adds a Languages section to the README explaining how the app picks its language and how another one would be added, a Simplified Chinese translation of the README, and a changelog entry.
model.macName is a delegated property, so Kotlin cannot smart cast it
from a null check to a non-null String. Two places used it that way
after the texts moved into the resources, and the build failed:
e: .../ui/DevicesScreen.kt:175:84 Smart cast to 'Any' is impossible,
because 'macName' is a delegated property.
e: .../ui/HomeScreens.kt:105:72 Smart cast to 'Any' is impossible,
because 'macName' is a delegated property.
Take it into a local val first: a local can be smart cast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
House Control for Android now speaks Simplified Chinese: the native screens, the widgets and
the bundled web UI (the 3D home, the panel, the floor plan editor and the connections).
The app follows the phone's language. On Android 13 and later it is also listed under
Settings → Apps → House Control → Language; on earlier releases it follows the system
language, as every other Android app does.
How it is put together
The native screens. Every label the app shows now comes from the string resources
instead of a Kotlin literal — 236 new entries in
app/src/main/res/values/strings.xml, withtheir Chinese wording in
app/src/main/res/values-zh-rCN/strings.xml. A newapp/src/main/res/xml/locales_config.xmlnames the app's languages, and the manifest pointsat it. No new dependency.
The web UI. The page is upstream's, and upstream keeps writing its labels as plain English
literals. Rather than rewriting them, the DOM helper (
web/src/ui/dom.js) passes every textnode and every readable attribute through a lookup, and a new dictionary
(
web/src/locales/zh-CN.js) holds the Chinese wording. The lookup falls back to the Englishtext when a label is not in the dictionary, so:
entry to keep working, and the dictionary does not have to be kept in step with the source.
The app tells the page which language it runs in through
window.__HOUSE_BOOT__.locale, whichHomeWeb.ktfills in from the app's own configuration.web/README.mdlists this alongsidethe other Android additions to that directory.What a reviewer can check
language settings on Android 13+.
cd web && npm install && npm run build).Notes and limits
happens to read exactly like a UI label ("Home", "On") is translated as well. Removing that
entry from the dictionary is enough to leave it alone.
which is what the resource qualifiers do as well — the two halves of the screen agree.
model.macNameis adelegated property, and Kotlin cannot smart cast one.
Commits
feat(i18n): add Simplified Chinese string resources— the resources and the locales configrefactor(i18n): read the native screens' text from resources— the Compose screens, thewidgets and the WebView's language
feat(i18n): translate the bundled web UI— the lookup and the dictionarydocs(i18n): document Chinese language support— a Languages section and a Chinese READMEfix(i18n): read the paired computer's name into a local before using it