TranslationsConfig class abstract

Abstract class that defines the configuration for translations. This class provides the foundation for how translations are handled, including parameter patterns, supported languages, and translation structure.

To create a custom configuration, extend this class and implement the copyWith method. For default configuration, use DefaultConfig.

Example:

class MyConfig extends TranslationsConfig {
  MyConfig() : super(
    absentValue: '??',
    paramPattern: RegExp(r'{(\w+)}'),
    supportedLanguages: {'en', 'es'},
    defaultLanguage: 'en',
    translations: {},
    translationsStructure: TranslationsStructureEnum.keyFirst,
    absentKey: 'MISSING_KEY'
  );

  @override
  TranslationsConfig copyWith({...}) => MyConfig(...);
}
Implementers

Constructors

TranslationsConfig.new({required String absentValue, required RegExp paramPattern, required Set<String> supportedLanguages, required String defaultLanguage, required Map<String, Map<String, String>> translations, required TranslationsStructureEnum translationsStructure, required String absentKey})
Creates a new translation configuration. All parameters are required to ensure proper functionality.
const

Properties

absentKey String
The message that will be returned if a translation key is not found. This helps identify missing translations during development.
final
absentValue String
The value that will be returned if a parameter is not found in the translation. Default is '??' in DefaultConfig.
final
defaultLanguage String
The fallback language code used when a requested language is not supported. Must be one of the codes in supportedLanguages.
final
hashCode int
The hash code for this object.
no setterinherited
paramPattern RegExp
The pattern used to identify dynamic parameters in translation strings. Default pattern in DefaultConfig is {paramName}.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedLanguages Set<String>
Set of language codes that your application supports. Language codes should follow ISO 639-1 format (e.g., 'en', 'es', 'fr').
final
supportedLocales List<Locale>
Get all supported locales for MaterialApp configuration
no setter
translations Map<String, Map<String, String>>
The translation data structure. Format depends on translationsStructure.
final
translationsStructure TranslationsStructureEnum
Determines how the translations map is structured. See TranslationsStructureEnum for details.
final

Methods

copyWith({String? absentValue, RegExp? paramPattern, Set<String>? supportedLanguages, String? defaultLanguage, Map<String, Map<String, String>>? translations, TranslationsStructureEnum? translationsStructure, String? absentKey}) TranslationsConfig
Creates a copy of this configuration with the specified fields replaced. Implement this method in your concrete configuration class.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited