Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: localize the vocalization in TtsModel #1280

Merged
merged 19 commits into from
Jul 23, 2024
Merged

Conversation

kevmo314
Copy link
Contributor

@kevmo314 kevmo314 commented Jul 7, 2024

NOTE: This doesn't work yet, we will need to figure out how to load the build context outside of a widget context in the tts isolate.

Localize the vocalization in TtsModel to address #1035.

  • Import AppLocalizations in lib/models/tts.dart and lib/screens/settings/tts.dart.
  • Update getVocalization method in TtsModel to use AppLocalizations for constructing vocalization strings.
  • Add BuildContext parameter to getVocalization method.
  • Update SystemMessageModel vocalizations to use localized strings.
  • Update the sample message in the ElevatedButton in TextToSpeechScreen to use AppLocalizations.
  • Add new localization strings for vocalization in lib/l10n/app_en.arb, lib/l10n/app_es.arb, lib/l10n/app_fr.arb, lib/l10n/app_de.arb, and lib/l10n/app_ja.arb.

For more details, open the Copilot Workspace session.

@kevmo314 kevmo314 changed the title Localize the vocalization in TtsModel feat: localize the vocalization in TtsModel Jul 8, 2024
@kevmo314
Copy link
Contributor Author

kevmo314 commented Jul 8, 2024

Three steps are necessary here:

  1. Resolve the correct locale. This can be done with
final locale = basicLocaleListResolution(WidgetsBinding.instance.platformDispatcher.locales, AppLocalizations.supportedLocales)

https://api.flutter.dev/flutter/widgets/basicLocaleListResolution.html

  1. Construct AppLocalizations:
final l10n = lookupAppLocalizations(Locale("en"));
  1. Update the AI-gen'd code to take l10n as an argument instead of BuildContext.

@kevmo314
Copy link
Contributor Author

@SputNikPlop looks good to me

lib/main.dart Outdated Show resolved Hide resolved
@SputNikPlop SputNikPlop enabled auto-merge (squash) July 23, 2024 20:07
@SputNikPlop SputNikPlop merged commit ec96b52 into main Jul 23, 2024
7 checks passed
@SputNikPlop SputNikPlop deleted the kevmo314/localize-tts branch July 23, 2024 20:09
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