feat: simplified digital ocean town name to country mapper.

pull/482/head
Aliaksei Tratseuski 2024-05-01 02:59:47 +04:00
parent 6eb5299d46
commit 844039e0f2
1 changed files with 14 additions and 39 deletions

View File

@ -77,46 +77,21 @@ class DigitalOceanLocation {
return emoji;
}
static const _townPrefixToCountryMap = {
'fra': 'germany',
'ams': 'netherlands',
'sgp': 'singapore',
'lon': 'united_kingdom',
'tor': 'canada',
'blr': 'india',
'syd': 'australia',
'nyc': 'united_states',
'sfo': 'united_states',
};
String get countryDisplayKey {
String displayKey = 'countries.';
switch (slug.substring(0, 3)) {
case 'fra':
displayKey += 'germany';
break;
case 'ams':
displayKey += 'netherlands';
break;
case 'sgp':
displayKey += 'singapore';
break;
case 'lon':
displayKey += 'united_kingdom';
break;
case 'tor':
displayKey += 'canada';
break;
case 'blr':
displayKey += 'india';
break;
case 'syd':
displayKey += 'australia';
break;
case 'nyc':
case 'sfo':
displayKey += 'united_states';
break;
default:
displayKey = slug;
}
return displayKey;
final countryName = _townPrefixToCountryMap[slug.substring(0, 3)] ?? slug;
return 'countries.$countryName';
}
}