Skip to content

In-app Persian (Farsi) localization with runtime language switching#43

Merged
iampedii merged 6 commits into
WhiteDNS:mainfrom
Danialsamadi:farsi-localization
May 18, 2026
Merged

In-app Persian (Farsi) localization with runtime language switching#43
iampedii merged 6 commits into
WhiteDNS:mainfrom
Danialsamadi:farsi-localization

Conversation

@Danialsamadi

Copy link
Copy Markdown
Contributor

Summary

Adds in-app language switching between English and Persian (فارسی) without changing the phone's system language. Mirrors the existing theme-switching system.

What's included

  • WhiteDnsStrings interface with EnglishStrings and PersianStrings implementations
  • LocalWhiteDnsStrings CompositionLocal and WhiteDnsL10n composable accessors
  • languageCode field added to WhiteDnsSettings, persisted via WhiteDnsSettingsStore
  • Language picker (segmented control) in the App Settings dialog
  • RTL layout direction applied automatically when Persian is selected
  • ~200 hardcoded English strings in WhiteDnsScreen.kt migrated to WhiteDnsL10n.*
  • Default profile names (Connection, Default Resolver, Default) are localized at render time via profile-id detection, while any user-renamed profiles keep their custom names
  • Localized SELECTED / MODIFIED status suffixes and the resolver-count summary on profile rows

Not in scope

  • Runtime VPN engine log output (English only)
  • Notification service strings (outside composable scope)
  • Profile names already stored by the user in JSON

- Add WhiteDnsLanguage object with En/Fa constants to WhiteDnsModels.kt
- Add languageCode field to WhiteDnsSettings data class with default En
- Add normalizeLanguageCode function for language code validation
- Call normalizeLanguageCode in syncSelectedConnectionProfileFields
- Add KeyLanguageCode constant to WhiteDnsSettingsStore
- Load languageCode from preferences in WhiteDnsSettingsStore.load()
- Save languageCode to preferences in WhiteDnsSettingsStore.save()

This fixes the issue where language changes weren't persisting across app restarts.
- Add LanguageModeSegmentedControl composable (English/فارسی toggle)
- Update AppSettingsDialog to show language picker below theme picker
- Update HeaderCard to accept and thread languageCode/onLanguageCodeChange
- Update all 4 HeaderCard call sites to wire language setting
- Update WhiteDnsTheme to accept languageCode and inject RTL layout direction
- Update MainActivity to pass languageCode to WhiteDnsTheme
… elements

- Create WhiteDnsStrings.kt interface with EnglishStrings and PersianStrings
- Add LocalWhiteDnsStrings and WhiteDnsL10n to WhiteDnsTheme.kt
- Inject correct strings based on languageCode into CompositionLocalProvider
- Replace key hardcoded visible strings with WhiteDnsL10n references:
  - Bottom tab labels (Profiles/Connect/Scan/Logs)
  - Connect button (CONNECT/CONNECTING/STOP)
  - App Settings dialog title and CLOSE button
  - Theme/Language field labels and option labels
  - Battery background banner text and action button
  - Profile tab headers (Connection/Resolver/Setting)
  - Parallel Test toggle label
…te strings

- Localize Mode field label (Mode / حالت)
- Localize connection mode buttons (Proxy Mode/Full VPN → حالت پروکسی/VPN کامل)
- Localize Connection/Resolver section headers
- Localize 'Server route missing' in all occurrences
- Fix ConnectionModeSegmentedControl to use localized option labels
- Add setupDefaultConnection/Resolver/Advanced strings to substitute
  localized labels when the user has not renamed the default profiles
- Wire id-based label override into setup card, home selectors,
  connection info card, advanced profile controls, and the three
  profile list rows (connection, resolver, settings)
- Localize the resolver row summary (count + SELECTED suffix) and
  the settings row MODIFIED/SELECTED status suffixes via new
  profileStatusModified and resolverProfileSummary entries
@iampedii iampedii merged commit 8f554c9 into WhiteDNS:main May 18, 2026
1 check passed
@Danialsamadi Danialsamadi deleted the farsi-localization branch May 18, 2026 02:55
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