resolveTextIntl method

String resolveTextIntl(
  1. String text
)

Resolves text {{intl:key}} messages.

Implementation

String resolveTextIntl(String text) {
  if (text.contains('{{')) {
    var uiRoot = this.uiRoot ?? UIRoot.getInstance();

    var intlMessageResolver = uiRoot?.intlMessageResolver;
    intlMessageResolver ??=
        (String key, [Map<String, dynamic>? parameters]) => key;

    return text.replaceAllMapped(_regexpIntlMessage, (m) {
      var key = m[1]!;
      return intlMessageResolver!(key) ?? key;
    });
  } else {
    return text;
  }
}