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() {
|
||||
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;
|
||||
for (String locale in localeToResources.keys) {
|
||||
|
@ -6,6 +6,10 @@
|
||||
// To regenerate the file, use:
|
||||
// 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>> {
|
||||
"ar": const <String, String>{
|
||||
"openAppDrawerTooltip": r"افتح قائمة التنقل",
|
||||
|
@ -52,6 +52,9 @@ abstract class MaterialLocalizations {
|
||||
class DefaultMaterialLocalizations implements MaterialLocalizations {
|
||||
/// Construct an object that defines the material widgets' localized strings
|
||||
/// for the given `locale`.
|
||||
///
|
||||
/// [LocalizationsDelegate] implementations typically call the static [load]
|
||||
/// function, rather than constructing this class directly.
|
||||
DefaultMaterialLocalizations(this.locale) {
|
||||
assert(locale != null);
|
||||
_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
|
||||
/// [Localizations] widget.
|
||||
///
|
||||
/// Typical applications have one [Localizations] widget which is
|
||||
/// created by the [WidgetsApp] and configured with the app's
|
||||
/// `localizationsDelegates` parameter.
|
||||
/// Typical applications have one [Localizations] widget which is created by the
|
||||
/// [WidgetsApp] and configured with the app's `localizationsDelegates`
|
||||
/// 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 const constructor. This constructor enables subclasses to provide
|
||||
/// const constructors so that they can be used in const expressions.
|
||||
@ -102,6 +103,17 @@ abstract class LocalizationsDelegate<T> {
|
||||
/// after [load] has completed.
|
||||
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;
|
||||
|
||||
@override
|
||||
@ -141,6 +153,11 @@ abstract class WidgetsLocalizations {
|
||||
|
||||
/// Localized values for widgets.
|
||||
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) {
|
||||
final String language = locale.languageCode.toLowerCase();
|
||||
_textDirection = _rtlLanguages.contains(language) ? TextDirection.rtl : TextDirection.ltr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user