get method

String get(
  1. String key, {
  2. Map<String, dynamic>? params,
})

Implementation

String get(String key, {Map<String, dynamic>? params}) {
  String? translation = _entries[key];

  if (translation == null) {
    return "??:$key";
  }

  // If no parameters provided, return translation as-is
  if (params == null || params.isEmpty) {
    return translation;
  }

  // Replace placeholders with actual values
  String result = translation;
  params.forEach((paramKey, paramValue) {
    result = result.replaceAll('{$paramKey}', paramValue.toString());
  });

  return result;
}