Skip to content

fix: package and load localized strings - #56

Closed
ZHUOLIN0928 wants to merge 1 commit into
momenbasel:mainfrom
ZHUOLIN0928:agent/simplified-chinese-localization
Closed

fix: package and load localized strings#56
ZHUOLIN0928 wants to merge 1 commit into
momenbasel:mainfrom
ZHUOLIN0928:agent/simplified-chinese-localization

Conversation

@ZHUOLIN0928

Copy link
Copy Markdown
Contributor

What changed

  • Package all .lproj directories in the app's main Contents/Resources directory.
  • Declare the supported bundle localizations, including Simplified Chinese, in Info.plist.
  • Use LocalizedStringKey for runtime-generated sidebar labels, picker tabs, status chips, badges, and reusable empty/loading states.
  • Complete the Simplified Chinese runtime string table and remove duplicate keys.
  • Add regression checks for localization packaging and runtime label handling.

Why

The existing build copied localization files only into the Swift Package resource bundle, while SwiftUI's implicit LocalizedStringKey lookup uses Bundle.main. As a result, the shipped app could show English labels even when a translated .strings file existed. Several views also constructed Text from String, bypassing localization lookup.

The patch keeps locale selection controlled by the user's system settings; it does not force Chinese for every user.

Validation

  • Scripts/regression/run.py: 67 checks passed.
  • Universal arm64+x86_64 release build passed with Xcode.
  • Built app contains root en, zh-Hans, ja, de, es, fr, and ar bundles.
  • Runtime check with system locale zh-Hans shows the sidebar in Simplified Chinese.

momenbasel added a commit that referenced this pull request Aug 10, 2026
…osed

Merged: #53 #58 #60 #62 #63 #67 #68 #69 #70
Closed as superseded: #54 (subsumed by #60)
Not merged, need rebase or rework: #55 #56 #57 #59 #61 #66
@momenbasel

Copy link
Copy Markdown
Owner

Thanks - and sorry this sat as a draft for a while. Reviewed for the v1.4.0 batch.

I checked the two release-critical files specifically, because those are the ones that can break a signed build, and both changes are safe:

  • Scripts/build.sh: the .lproj copy loop is correctly placed after the universal build and the binary copy, reads from the source tree rather than the build output, and targets a different destination than the SPM resource bundle, so it does not disturb either. The glob is guarded with [ -d ], so an unmatched pattern is a no-op rather than a set -e trip.
  • Resources/Info.plist: CFBundleLocalizations is metadata only. Bundle identifier, executable name and both version keys are untouched, so codesigning, notarization and the cask's app "Phosphor.app" stanza are unaffected.

Two things before it lands:

  1. EmptyStateView passes runtime error text through LocalizedStringKey(subtitle). A dynamic string containing % format tokens gets mangled or blanked. Use Text(verbatim:) for anything that is already a resolved message rather than a key.
  2. Rebase. Scripts/build.sh and Info.plist both changed in v1.4.0 - the release now stamps CFBundleShortVersionString from the tag, so keep that stamping intact. WhatsAppExporter.swift also moved under feat: improve message exports and preserve attachments #58.

Mark it ready for review when you have rebased and I will take another pass.

momenbasel added a commit that referenced this pull request Aug 12, 2026
Co-authored-by: ZHUOLIN0928 <270883937+ZHUOLIN0928@users.noreply.github.com>
@momenbasel momenbasel closed this Aug 12, 2026
@momenbasel

momenbasel commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Closing the loop on this one: the Simplified Chinese localization shipped in #71, which was a maintainer rebuild of this PR.

Why a rebuild instead of a direct merge: this PR had maintainerCanModify disabled, so I could not push the needed fixes to the branch directly. Rather than let the work go stale, I recreated it on a maintainer branch with two corrections:

  • The .lproj bundles were never copied into the app bundle by Scripts/build.sh, so the strings table was dead weight at runtime — the build script now packages every .lproj directory.
  • EmptyStateView wrapped dynamic subtitles in LocalizedStringKey, which format-reinterprets runtime error messages containing %; it now does an explicit table lookup and renders non-key strings verbatim.

All 280+ translations from this PR were carried over unchanged, and regression checks now cover the packaging and runtime label handling. Full credit to @ZHUOLIN0928 for the translation work — thank you, and apologies for the indirect route. Future PRs with "Allow edits by maintainers" enabled can be fixed up and merged in place.

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