AssetLocalizations class
Localization support using assets files.
Use translate to translate any text.
All translations should be put in the assets/lang/
folder as json files,
one for each local (e.g., en.json
or da.json
). Note that only the
languageCode
of a Locale
is used.
Remember to add the assets/lang/
folder to the list of assets
in the
pubspec.yaml
file like this:
flutter:
assets:
- assets/lang/
...
- Implementers
Constructors
- AssetLocalizations.new(Locale locale)
-
Create an assets localization based on
locale
.
Properties
Methods
-
canTranslate(
String key) → bool -
Can this
key
be translated by this localization? -
load(
) → Future< bool> - Load the translations from filename based on the locale.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
translate(
String key) → String -
Translate
key
to this locale. Ifkey
is not translated,key
is returned 'as-is'.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
of(
BuildContext context) → AssetLocalizations? -
Returns the localized resources object of type AssetLocalizations for the
widget tree that corresponds to the given
context
.
Constants
-
delegate
→ const LocalizationsDelegate<
AssetLocalizations> - A default LocalizationsDelegate for AssetLocalizations.