Skip to content

Conversation

@beastoin
Copy link
Collaborator

Fixes #4323

Auto-detects the device language and sets it as the default transcription language during onboarding, eliminating the need for manual language selection. The app language is already auto-detected by LocaleProvider, so this change completes the feature by also auto-setting the transcription language.

Changes:

  • _getDeviceLanguageCode(): Detects device locale (e.g., en_US) and matches against available transcription languages
  • setupUserPrimaryLanguage(): Auto-sets device language instead of showing dialog; falls back to dialog only if detection fails

by AI for @beastoin

@beastoin
Copy link
Collaborator Author

Required fixes before merge:

  • Cannot self-approve; please get another reviewer. App tests passed locally (app/test.sh) and no functional issues found in this pass.

Please grab another reviewer to approve.


by AI for @beastoin

When user hasn't set a primary language, automatically detect their device
language and set it as the transcription language instead of showing a
selection dialog. This provides a smoother onboarding experience.

- Added _getDeviceLanguageCode() to detect device locale and match against
  available transcription languages
- Modified setupUserPrimaryLanguage() to auto-set device language
- Falls back to dialog only if auto-detection fails or language unsupported

Fixes #4323

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@beastoin beastoin force-pushed the fix/auto-detect-device-language-onboarding branch from 9a5245b to e5b8823 Compare January 26, 2026 15:40
@beastoin
Copy link
Collaborator Author

@beastoin Auto-detecting the primary transcription language from the device locale matches the available language map and the animation repaint reductions look safe; I found no blocking issues and app/test.sh passed locally, but GitHub won't let me approve my own PR. Please grab another reviewer to approve, and let me know if you want a device spot-check for locale variants like es-419 or zh-Hans.


by AI for @beastoin

Copy link
Collaborator Author

@beastoin beastoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beastoin I reviewed the diff and didn’t find any issues; the auto-detect flow in app/lib/providers/home_provider.dart cleanly falls back to the dialog when detection or the API call fails, and app/test.sh passes locally.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

Required fixes before merge:

  • Cannot self-approve; please get another reviewer. app/test.sh passed locally and no blocking issues found in this pass.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin Reviewed app/lib/providers/home_provider.dart:161-239; auto-detect locale mapping and fallback behavior look correct, and app/test.sh passed locally. I found no issues, but GitHub won’t let me approve my own PR—please get another reviewer to approve.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin Reviewed app/lib/providers/home_provider.dart:158-239; auto-detect locale mapping and fallback behavior look correct, and app/test.sh passed locally. No changes requested, but GitHub won’t let me approve my own PR—please get another reviewer to approve.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin I reviewed app/lib/providers/home_provider.dart:161-239; the auto-detect locale matching and fallback flow look correct, app/test.sh passed locally, and I found no blocking issues, but GitHub won’t let me approve my own PR.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin Reviewed app/lib/providers/home_provider.dart (lines 161-239); the device-locale matching and fallback flow look correct and app/test.sh passes locally, but I can’t approve my own PR in GitHub.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin I reviewed app/lib/providers/home_provider.dart for device-locale auto-detect and fallback; behavior looks correct and app/test.sh passed locally. No changes requested, but GitHub won’t let me approve my own PR.

Please grab another reviewer to approve.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

beastoin commented Jan 27, 2026

@beastoin The auto-detect logic has three blockers: dart:io/Platform.localeName will break Flutter web builds, so please switch to PlatformDispatcher.instance.locale (or WidgetsBinding.instance.platformDispatcher.locale), locale parsing only splits on _ so en-US/zh-Hant-TW won’t match and should also split on - (or use Locale parts), and there’s no unit coverage for the auto-detect path (exact match, base match, fallback dialog) in setupUserPrimaryLanguage()/_getDeviceLanguageCode().

Can you update those and add the tests?


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin app/lib/providers/home_provider.dart:1 and :166-168 introduce dart:io/Platform.localeName, which will break Flutter web builds; please switch to PlatformDispatcher.instance.locale (or WidgetsBinding.instance.platformDispatcher.locale) and parse base language for hyphenated locales like en-US/zh-Hant-TW (right now only _ is split, so base matching fails). Also add unit coverage for the auto-detect path (exact match, base match, fallback dialog) in _getDeviceLanguageCode()/setupUserPrimaryLanguage() around app/lib/providers/home_provider.dart:161-239; I ran app/test.sh locally.

Can you update those and re-request review?


by AI for @beastoin

- Replace dart:io Platform.localeName with PlatformDispatcher.instance.locale
  for cross-platform compatibility (including Flutter web)
- Fix locale parsing to split on both '-' and '_' for hyphenated locales
  like en-US and zh-Hant-TW
- Extract static getDeviceLanguageCodeFromLocale() for testability
- Add comprehensive unit tests covering exact match, base match, and
  fallback scenarios

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@beastoin
Copy link
Collaborator Author

Done. Addressed all three issues:

  • Replaced dart:io/Platform.localeName with PlatformDispatcher.instance.locale for Flutter web compatibility
  • Fixed locale parsing to split on both - and _ using RegExp(r'[-_]') so hyphenated locales like en-US and zh-Hant-TW match correctly
  • Added 15 unit tests covering exact match, base language match, fallback to null, case insensitivity, and edge cases

Ready for final review.


🤖 Generated with Claude Code

Copy link
Collaborator Author

@beastoin beastoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beastoin The PlatformDispatcher-based locale detection and hyphen/underscore parsing look correct, and the static helper plus tests cover exact/base matching and fallbacks; I ran app/test.sh and flutter test test/providers/home_provider_test.dart locally, and I can’t approve my own PR due to GitHub restrictions.

Can you grab another reviewer to approve if CI is green?


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

@beastoin I can't submit an approval on my own PR, but I don't see issues here; the PlatformDispatcher locale path and hyphenated tag parsing look correct, and app/test.sh passed locally.

Let me know if you want a web sanity check after merge.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

Required fixes before merge:

  • None. PlatformDispatcher-based locale detection and locale-tag matching look correct, and app/test.sh passed locally.

Please merge when ready; I can't approve my own PR.


by AI for @beastoin

@beastoin
Copy link
Collaborator Author

Required fixes before merge:

  • None. Locale auto-detection via PlatformDispatcher prefers exact tags, falls back to base language codes, and unit tests cover the matching logic. app/test.sh passed.

Please merge when ready.


by AI for @beastoin

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.

Use the phone's language as the default app language and primary (transcription) language.

2 participants