No. However, if you want to cover more variations of the language (e.g. `es-ES`, `es-MX`, etc.), then it is required. The same applies to script codes (e.g. `zh-Hans`, `zh-Hant`, etc.). It should also be noted that it is a good practice to have a generic fallback language in order to avoid wrong language resolution.
You can use the ICU Message syntax to include placeholders. That will allow you to handle almost anything, from a simple text input to formatting numbers, dates, times, plurals, and other data types.
Overriding the inherited locale and localizations delegates for a child widget is pretty easy in Flutter. For that purpose, you only need to wrap the desired widget with the `Localizations.override` factory constructor.
Read `WidgetsBinding.instance.platformDispatcher.locales` for the user's preferred languages in order (`.locale` is the first one). Inside the widget tree, `Localizations.localeOf(context)` gives the locale the app actually resolved from `supportedLocales`.
The `flutter_localizations` package ships inside the Flutter SDK with its own `intl` constraint, so a different constraint in your `pubspec.yaml` or in another package cannot be resolved. Use the `any` constraint for `intl`, match the version the SDK requires, or upgrade the conflicting package.
Discover how to detect unused string keys in Flutter ARB files with our example code. By creating a command line program based on this example, you can easily streamline your localization process and improve the efficiency and organization of your Flutter project.
Learn how to download localization files at runtime and use them in your Flutter app. Discover how to implement Over-the-Air translations update with Localizely to keep your app up-to-date with the latest translations without releasing a new version.
Dart does not have square brackets property accessor (`object['property']`) on class instances. Therefore, it is not possible to access localization messages in that way. However, if you want to access a certain message according to the value of a variable (e.g. the value returned from the server), you can use the ICU Select type of messages. These messages work well with a smaller set of predefined values like constants and enums.
Learn how to localize your Flutter app's name with this step-by-step guide for iOS and Android platforms. Ensure your app name is properly translated and accessible to users in their preferred language.
The Flutter app and server (regular backend app, Firestore, etc.) are two separate entities that communicate over a network. Thus, the localization of both entities should be independent. The only thing that matters here is that the languages in the Flutter app and on the server side match. For that purpose, it is necessary to extend the server API endpoints with a language parameter to make the communication between these two entities compatible.
To permanently save the app settings in Flutter, you need to store them somewhere on the device or the server. The easiest way to achieve that is with the help of the shared_preferences package.
There are several ways this can be done. The main thing is to explicitly set the `locale` prop of the `MaterialApp` widget on language change.
In general, there is no clean solution here. In most cases, you'll end up with tightly coupled app layers. Passing the context to the non-widget piece of the code (e.g. model class) that needs to be localized is perhaps the simplest approach.
Learn how to use localized date in Flutter with the DateFormat class. Format dates in the user's locale and display them in a familiar format. Examples included.
Learn how to use localized number in Flutter with the NumberFormat class. Format numbers in the user's locale and display them in a familiar format. Examples included.
Learn how to define non-translatable strings in Flutter ARB files. Find out how to maintain consistency in your app's translations by using the same translation or a glossary in translation management systems. Read more here.
Learn how to translate your Flutter app for free using machine translation tools like Google Translate, but discover why using a translation management platform like Localizely offers more comprehensive features to improve the quality and efficiency of your app's localization process.
Flutter 3.32 stopped generating the synthetic `flutter_gen` package; `flutter gen-l10n` now writes `app_localizations.dart` into your source tree, by default under `lib/l10n`. Import it from there and remove `synthetic-package` from `l10n.yaml`.
At least one delegate type has no delegate that supports the resolved locale, usually because the `flutter_localizations` delegates are missing. Pass `GlobalMaterialLocalizations.delegates` (or the generated `AppLocalizations.localizationsDelegates`) to `MaterialApp.localizationsDelegates`.
Because `DateFormat` was used with a locale other than `en_US` before the date symbols were loaded. Call `await initializeDateFormatting()` from `package:intl/date_symbol_data_local.dart` before the first format call, for example in `main` before `runApp`.
Learn why Flutter may not generate the necessary localization files and how configuration issues with gen_l10n and cache problems with Flutter Intl are among the common reasons. Discover how to overcome these obstacles and generate the required localization files.
Flutter automatically sets the appropriate text direction according to the selected locale. In case you have this problem and you don't know what the cause is, check if somewhere above in the widget tree you have explicitly specified the text direction (e.g. usage of the `Directionality` widget) and if your localization library requires some additional settings.
Learn why localization in Flutter may not work on iOS platform and how to fix it. Discover why updating the Info.plist file with supported locales is crucial for successful localization in iOS and how it differs from Android app localization.
If you're encountering a null value when attempting to access AppLocalizations.of(context) in your Flutter app, it's likely due to incorrect localization configuration. This could be caused by a failure to register AppLocalizations.delegate in the localizationsDelegates of your MaterialApp widget, or by trying to access localization messages before they are ready. Read more to find the solution.