Solution: Internationalizing the Application
Explore the solutions to the app internationalization challenge.
Solutions
Great job on completing all the steps in the previous challenge! Feel free to compare your code solutions with the solutions below:
Solution 1: Set up flutter_localizations
First, we add the flutter_localizations
library to the pubspec.yaml
file.
# SOLUTION-1: Include flutter_localizations
flutter_localizations:
sdk: flutter
Solution 2: Enable code generation
Then, we enable code generation in pubspec.yaml
to enable the generation of localization files.
flutter:
# SOLUTION-2: Enable code generation
generate: true
Solution 3: Set localization delegates and supported locales
Next, we import the AppLocalizations
class from package:flutter_gen/gen_l10n/app_localizations.dart
and use it to set up localizationsDelegates
and ...