formatLanguageList function
Formats a list of language codes with their native names.
Useful for displaying language options to users.
Example:
final formatted = formatLanguageList(['en', 'fr', 'de']);
// Returns: ['English (en)', 'Français (fr)', 'Deutsch (de)']
Implementation
List<String> formatLanguageList(List<String> codes) {
return codes.map((code) {
final info = getLanguageInfo(code);
if (info != null) {
return '${info.nativeName} (${info.code})';
} else {
return code;
}
}).toList();
}