localized method

String localized(
  1. String key,
  2. String orElse, {
  3. String? locale,
  4. String localizationValueKey = MetaConst.translate,
})

Get the translated data stored in key.

If there is no data in key, it is replaced by the data in orElse.

Specify the language in locale.

localizationValueKey is the suffix of the data that contains the translated map.

Implementation

String localized(
  String key,
  String orElse, {
  String? locale,
  String localizationValueKey = MetaConst.translate,
}) {
  locale ??= Localize.language;
  final map = this.get(
    "$key$localizationValueKey",
    const <String, dynamic>{},
  );
  if (map.isEmpty) {
    return this.get(key, orElse);
  }
  return map.get(
    locale,
    this.get(key, orElse),
  );
}