[gen_l10n] Generate static localization keys #67092
Labels
a: internationalization
Supporting other languages or locales. (aka i18n)
c: proposal
A detailed proposal for a change to Flutter
framework
flutter/packages/flutter repository. See also f: labels.
P3
Issues that are less important to the Flutter project
team-framework
Owned by Framework team
tool
Affects the "flutter" command-line tool. See also t: labels.
triaged-framework
Triaged by Framework team
Projects
Use case
My business logic is executed in a separate class (ViewModel/BLoC pattern) that doesn't have access to Flutter's
BuildContext
. However, I need to pass localized messages back to the UI in a reactive way (via StreamController/PublishSubject).ViewModel class:
Screen widget:
Proposal
The gen_l10n tool should generate static keys which can be resolved into localized messages when the
BuildContext
is available.That's how Android basically manages all kinds of resources like strings, dimensions or colors. The resource IDs (automatically generated integer constants) can be referenced from anywhere (R.string.submission_error), but can only be converted into strings within the application context.
Example usage:
Or with an extension function:
context.getString(localeKey)
The text was updated successfully, but these errors were encountered: