CustomLanguage class
class LanguageModel extends CustomLanguage {
@override
Map<String, LanguageInstance> get addedLanguages => {
'am': LangAmharic(),
'en': LangEnglish()
};
@override
List<LangModel> get globalAccessableValues => [
LangModel('name_e', 'name_english'),
LangModel('name_a', 'name_amharic')
];
LanguageModel({
@required String langCode
}) : super(langCode: langCode);
}
Methods
-
get(String langKey, {String alt = '', List append = const []})
→ String
-
this function returns the associated value of the langKey that means the first parameter of
LangModel
and if there is any value that the language model accepts it appends respectively
for example if we assume that itemsAdded
holds the below value
for English You have added $replaceString item(s)
for Amharic $replaceString እቃ(ዎችን) አክለዋል
-
getAvailableLanguages()
→ List<DropdownLangModel>
-
returns all the available languages as a dropdown model
-
join(String joiner, {List values})
→ String
-
this function joins an array with a string
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a non-existent method or property is accessed.
inherited
-
parse(dynamic value, {List<String> keys = const [], String append = ""})
→ List<String>
-
this function parses values from a
JSON
Object with multible language dependences
for example if we have a values the come from an Api call or something like this
-
set(List value, {int index = -1})
→ String
-
this function gets a value from the an array and returns a String based on the selected language
if the length of the array passed is less than the available languages it return the first value of the array
assume if we have a product with two different name like below
-
setCurrentLanguage()
→ dynamic
-
this function set the current language values from its respective class
or refresh if there is any changes made
and adds the
globalAccessableValues
to the model
-
toString()
→ String
-
A string representation of this object.
inherited
-
withCode({String langCode})
→ CustomLanguage
-
this function will be used to call other language models directly from the currently selected language model
for example if the current selected language is
English
and i wanted to access others language values without changing
the currently selected language like Amharic
i can do it like this with language code am