i18n method

Tries to translate given key based on current language code collected from locale. If it fails to translate key, it will return key itself.

Implementation

String i18n(AliceTranslationKey key) {
  try {
    final locale = Localizations.localeOf(this);
    return AliceTranslations.get(languageCode: locale.languageCode, key: key);
  } catch (error) {
    return key.toString();
  }
}