translate method

String translate(
  1. Symbol key
)

Implementation

String translate(Symbol key) {
  final message = _localizedValues[key];
  if (message == null) {
    if (_debug) {
      var debug = false;
      assert(() {
        debug = true;
        return true;
      }());
      if (debug) {
        return '[$key]!!';
      }
    }

    throw JsonIntlException('The translation key [$key] was not found');
  }

  var value = message.get(
    JsonIntlGender.neutral,
    JsonIntlPlural.other,
    null,
  );
  if (value == null) {
    if (_debug) {
      var debug = false;
      assert(() {
        debug = true;
        return true;
      }());
      if (debug) {
        return '[$key]!!';
      }
    }

    throw JsonIntlException(
        'Unable to build a translation for [$key]\n  Gender: neutral\n  Plural: other');
  }

  assert(() {
    if (_debug) {
      value = '[$key]($value)';
    }
    return true;
  }());

  return value!;
}