TrX extension

Extension on String that provides translation functionality. This extension allows you to easily translate strings using the configured translations.

Supports up to 3 dynamic parameters that can be replaced in the translation string. The translation key itself does not contain parameter placeholders - instead, the parameters are defined in the translation value and matched by their keys.

Example:

// Simple translation
'welcome_message'.tr('en'); // Output: 'Welcome!'

// Translation with one parameter
// If translation is "Hello {name}!"
'greeting'.tr('en', ParamModel(key: 'name', value: 'John')); 
// Output: 'Hello John!'

// Translation with multiple parameters
// If translation is "Hello {title} {name}!"
'formal_greeting'.tr('en',
  ParamModel(key: 'title', value: 'Mr.'),
  ParamModel(key: 'name', value: 'John')
); // Output: 'Hello Mr. John!'

Todo(Sharaf): Add more parameters constructor

on

Methods

tr(String? languageCode, [ParamModel? param1, ParamModel? param2, ParamModel? param3]) String

Available on String, provided by the TrX extension

Translates the string to the specified language, with optional parameters.