Added missing Localizations API doc (#11896)
This commit is contained in:
parent
7b33efb620
commit
f3fe875714
@ -68,7 +68,12 @@ String generateString(String s) {
|
|||||||
String generateLocalizationsMap() {
|
String generateLocalizationsMap() {
|
||||||
final StringBuffer output = new StringBuffer();
|
final StringBuffer output = new StringBuffer();
|
||||||
|
|
||||||
output.writeln('const Map<String, Map<String, String>> localizations = const <String, Map<String, String>> {');
|
output.writeln('''
|
||||||
|
/// Maps from [Locale.languageCode] to a map that contains the localized strings
|
||||||
|
/// for that locale.
|
||||||
|
///
|
||||||
|
/// This variable is used by [MaterialLocalizations].
|
||||||
|
const Map<String, Map<String, String>> localizations = const <String, Map<String, String>> {''');
|
||||||
|
|
||||||
final String lastLocale = localeToResources.keys.last;
|
final String lastLocale = localeToResources.keys.last;
|
||||||
for (String locale in localeToResources.keys) {
|
for (String locale in localeToResources.keys) {
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
// To regenerate the file, use:
|
// To regenerate the file, use:
|
||||||
// dart gen_localizations packages/flutter/lib/src/material/i18n material
|
// dart gen_localizations packages/flutter/lib/src/material/i18n material
|
||||||
|
|
||||||
|
/// Maps from [Locale.languageCode] to a map that contains the localized strings
|
||||||
|
/// for that locale.
|
||||||
|
///
|
||||||
|
/// This variable is used by [MaterialLocalizations].
|
||||||
const Map<String, Map<String, String>> localizations = const <String, Map<String, String>> {
|
const Map<String, Map<String, String>> localizations = const <String, Map<String, String>> {
|
||||||
"ar": const <String, String>{
|
"ar": const <String, String>{
|
||||||
"openAppDrawerTooltip": r"افتح قائمة التنقل",
|
"openAppDrawerTooltip": r"افتح قائمة التنقل",
|
||||||
|
@ -52,6 +52,9 @@ abstract class MaterialLocalizations {
|
|||||||
class DefaultMaterialLocalizations implements MaterialLocalizations {
|
class DefaultMaterialLocalizations implements MaterialLocalizations {
|
||||||
/// Construct an object that defines the material widgets' localized strings
|
/// Construct an object that defines the material widgets' localized strings
|
||||||
/// for the given `locale`.
|
/// for the given `locale`.
|
||||||
|
///
|
||||||
|
/// [LocalizationsDelegate] implementations typically call the static [load]
|
||||||
|
/// function, rather than constructing this class directly.
|
||||||
DefaultMaterialLocalizations(this.locale) {
|
DefaultMaterialLocalizations(this.locale) {
|
||||||
assert(locale != null);
|
assert(locale != null);
|
||||||
_nameToValue = localizations[locale.toString()]
|
_nameToValue = localizations[locale.toString()]
|
||||||
|
@ -78,9 +78,10 @@ Future<Map<Type, dynamic>> _loadAll(Locale locale, Iterable<LocalizationsDelegat
|
|||||||
/// A factory for a set of localized resources of type `T`, to be loaded by a
|
/// A factory for a set of localized resources of type `T`, to be loaded by a
|
||||||
/// [Localizations] widget.
|
/// [Localizations] widget.
|
||||||
///
|
///
|
||||||
/// Typical applications have one [Localizations] widget which is
|
/// Typical applications have one [Localizations] widget which is created by the
|
||||||
/// created by the [WidgetsApp] and configured with the app's
|
/// [WidgetsApp] and configured with the app's `localizationsDelegates`
|
||||||
/// `localizationsDelegates` parameter.
|
/// parameter (a list of delegates). The delegate's [type] is used to identify
|
||||||
|
/// the object created by an individual delegate's [load] method.
|
||||||
abstract class LocalizationsDelegate<T> {
|
abstract class LocalizationsDelegate<T> {
|
||||||
/// Abstract const constructor. This constructor enables subclasses to provide
|
/// Abstract const constructor. This constructor enables subclasses to provide
|
||||||
/// const constructors so that they can be used in const expressions.
|
/// const constructors so that they can be used in const expressions.
|
||||||
@ -102,6 +103,17 @@ abstract class LocalizationsDelegate<T> {
|
|||||||
/// after [load] has completed.
|
/// after [load] has completed.
|
||||||
bool shouldReload(covariant LocalizationsDelegate<T> old);
|
bool shouldReload(covariant LocalizationsDelegate<T> old);
|
||||||
|
|
||||||
|
/// The type of the object returned by the [load] method, T by default.
|
||||||
|
///
|
||||||
|
/// This type is used to retrieve the object "loaded" by this
|
||||||
|
/// [LocalizationsDelegate] from the [Localizations] inherited widget.
|
||||||
|
/// For example the object loaded by `LocalizationsDelegate<Foo>` would
|
||||||
|
/// be retrieved with:
|
||||||
|
/// ```dart
|
||||||
|
/// Foo foo = Localizations.of<Foo>(context, Foo);
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// It's rarely necessary to override this getter.
|
||||||
Type get type => T;
|
Type get type => T;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -141,6 +153,11 @@ abstract class WidgetsLocalizations {
|
|||||||
|
|
||||||
/// Localized values for widgets.
|
/// Localized values for widgets.
|
||||||
class DefaultWidgetsLocalizations implements WidgetsLocalizations {
|
class DefaultWidgetsLocalizations implements WidgetsLocalizations {
|
||||||
|
/// Construct an object that defines the localized values for the widgets
|
||||||
|
/// library for the given `locale`.
|
||||||
|
///
|
||||||
|
/// [LocalizationsDelegate] implementations typically call the static [load]
|
||||||
|
/// function, rather than constructing this class directly.
|
||||||
DefaultWidgetsLocalizations(this.locale) {
|
DefaultWidgetsLocalizations(this.locale) {
|
||||||
final String language = locale.languageCode.toLowerCase();
|
final String language = locale.languageCode.toLowerCase();
|
||||||
_textDirection = _rtlLanguages.contains(language) ? TextDirection.rtl : TextDirection.ltr;
|
_textDirection = _rtlLanguages.contains(language) ? TextDirection.rtl : TextDirection.ltr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user