Unverified Commit f16a569e authored by Gary Qian's avatar Gary Qian Committed by GitHub

Supported locales docs to explain proper scriptCode usage. (#24184)

parent 58397108
......@@ -560,6 +560,34 @@ class WidgetsApp extends StatefulWidget {
/// [supportedLocales] with a matching [Locale.languageCode] is used. If that
/// fails then the first locale in [supportedLocales] is used. The default
/// locale resolution algorithm can be overridden with [localeResolutionCallback].
///
/// When supporting languages with more than one script, it is recommended
/// to specify the [Locale.scriptCode] explicitly. Locales may also be defined without
/// [Locale.countryCode] to specify a generic fallback for a particular script.
///
/// A fully supported language with multiple scripts should define a generic language-only
/// locale (eg. 'zh'), language+script only locales (eg. 'zh_Hans' and 'zh_Hant'),
/// and any language+script+country locales (eg. 'zh_Hans_CN'). Fully defining all of
/// these locales as supported is not strictly required but allows for proper locale resolution in
/// the most number of cases. These locales can be specified with the [Locale.fromSubtags]
/// constructor:
///
/// ```dart
/// // Full Chinese support for CN, TW, and HK
/// supportedLocales: [
/// const Locale.fromSubtags(languageCode: 'zh'), // generic Chinese 'zh'
/// const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans'), // generic simplified Chinese 'zh_Hans'
/// const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'), // generic traditional Chinese 'zh_Hant'
/// const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hans', countryCode: 'CN'), // 'zh_Hans_CN'
/// const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'TW'), // 'zh_Hant_TW'
/// const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'HK'), // 'zh_Hant_HK'
/// ],
/// ```
///
/// Omitting some these fallbacks may result in improperly resolved
/// edge-cases, for example, a simplified Chinese user in Taiwan ('zh_Hans_TW')
/// may resolve to traditional Chinese if 'zh_Hans' and 'zh_Hans_CN' are
/// omitted.
/// {@endtemplate}
///
/// See also:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment