localize static method

String localize(
  1. String key, {
  2. String? name,
  3. String? defaultValue,
  4. bool applyNumber = false,
  5. bool applyRtl = false,
  6. bool applyTranslator = true,
  7. String replace(
    1. String
    )?,
  8. Map<String, Object?>? args,
})
final inp1 = "There {NUMBER > 1 ? \"are NUMBER items\" : \"is an item\"} in stock";
Translation.lt("key", defaultValue: inp1, args: {'NUMBER': 1}); // There is an item in stock
Translation.lt("key", defaultValue: inp1, args: {'NUMBER': 2}); // There are 2 items in stock

final inp2 = "Status: {STATUS == active ? \"activated!\" : \"canceled!\"}";
Translation.lt("key", defaultValue: inp2, args: {'STATUS': "active"}); // Status: activated!
Translation.lt("key", defaultValue: inp2, args: {'STATUS': "inactive"}); // Status: canceled!

final inp3 = "Status: {IS_ACTIVATED ? \"activated!\" : \"inactivated!\"}";
Translation.lt("key", defaultValue: inp3, args: {'IS_ACTIVATED': true}); // Status: activated!
Translation.lt("key", defaultValue: inp3, args: {'IS_ACTIVATED': false}); // Status: inactivated!

final inp4 = "Last seen: {TIME: {a:now, b:3 min ago}}";
Translation.lt("key", defaultValue: inp4, args: {"TIME": "a"}); // Last seen: now
Translation.lt("key", defaultValue: inp4, args: {"TIME": "b"}); // Last seen: 3 min ago

Implementation

static String localize(
  String key, {
  String? name,
  String? defaultValue,
  bool applyNumber = false,
  bool applyRtl = false,
  bool applyTranslator = true,
  String Function(String)? replace,
  Map<String, Object?>? args,
}) {
  return i._lt(
    key,
    name: name,
    defaultValue: defaultValue,
    applyNumber: applyNumber,
    applyTranslator: applyTranslator,
    applyRtl: applyRtl,
    replace: replace,
    args: args,
  );
}