class OTPMessages { static final Map> translations = { "code correct": { "en": "Code correct", "fr": "Code correct", "ar": "الرمز صحيح", }, "this code is expired": { "en": "This code is expired", "fr": "Ce code est expiré", "ar": "هذا الرمز منتهي الصلاحية", }, "this code is not valid": { "en": "This code is not valid", "fr": "Ce code n'est pas valide", "ar": "هذا الرمز غير صالح", }, "this code is wrong": { "en": "This code is wrong", "fr": "Ce code est incorrect", "ar": "هذا الرمز خاطئ", }, }; static String get(String result, String langCode) { String key; if (result == null) { key = "code correct"; } else if (result == "expired") { key = "this code is expired"; } else if (result == "invalidToken") { key = "this code is not valid"; } else { key = "this code is wrong"; } return translations[key]?[langCode] ?? key; } }