codeTranslations property

Translations<dynamic, Map<StringLocale, StringTranslated>, Map<dynamic, StringTranslated>, dynamic>? codeTranslations
getter/setter pair

If you use error codes, you may provide their respective text messages here, by providing a Translations object from the i18n_extension package. You can only provide messages in English, or in multiple other languages.

If you are NOT using the i18n_extension, you can ignore codeTranslations and instead just modify the translateCode method to return a string from the code.

Example with English only:

UserException.codeTranslations = Translations.byId<int>('en', {
   1: { 'en': 'Invalid email' },
   2: { 'en': 'There is no connection' },
});

Example with multiple languages:

UserException.codeTranslations = Translations.byId<int>('en', {
   1: { 'en': 'Invalid email', 'pt': 'Email inválido' },
   2: { 'en': 'There is no connection', 'pt': 'Não há conexão' },
});

Implementation

static Translations? codeTranslations;