diff --git a/assets/translations/en.json b/assets/translations/en.json index b862cba6..f5194cdd 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -606,5 +606,16 @@ "reset_onboarding": "Reset onboarding switch", "reset_onboarding_description": "Reset onboarding switch to show onboarding screen again", "cubit_statuses": "Cubit loading statuses" + }, + "countries": { + "germany": "Germany", + "netherlands": "Netherlands", + "singapore": "Singapore", + "united_kingdom": "United Kingdom", + "canada": "Canada", + "india": "India", + "australia": "Australia", + "united_states": "United States", + "finland": "Finland" } -} +} \ No newline at end of file diff --git a/lib/logic/models/json/digital_ocean_server_info.dart b/lib/logic/models/json/digital_ocean_server_info.dart index 811536e4..dbe41f66 100644 --- a/lib/logic/models/json/digital_ocean_server_info.dart +++ b/lib/logic/models/json/digital_ocean_server_info.dart @@ -65,14 +65,59 @@ class DigitalOceanLocation { emoji = '🇮🇳'; break; + case 'syd': + emoji = '🇦🇺'; + break; + case 'nyc': case 'sfo': emoji = '🇺🇸'; break; } - return emoji; } + + 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; + } } @JsonSerializable() diff --git a/lib/logic/models/json/hetzner_server_info.dart b/lib/logic/models/json/hetzner_server_info.dart index 122d0288..a0559de6 100644 --- a/lib/logic/models/json/hetzner_server_info.dart +++ b/lib/logic/models/json/hetzner_server_info.dart @@ -155,6 +155,27 @@ class HetznerLocation { } return emoji; } + + String get countryDisplayKey { + String displayKey = 'countries.'; + switch (country.substring(0, 2)) { + case 'DE': + displayKey += 'germany'; + break; + + case 'FI': + displayKey += 'finland'; + break; + + case 'US': + displayKey += 'united_states'; + break; + + default: + displayKey = country; + } + return displayKey; + } } /// A Volume is a highly-available, scalable, and SSD-based block storage for Servers. diff --git a/lib/logic/models/server_provider_location.dart b/lib/logic/models/server_provider_location.dart index 688eb972..09188651 100644 --- a/lib/logic/models/server_provider_location.dart +++ b/lib/logic/models/server_provider_location.dart @@ -2,12 +2,14 @@ class ServerProviderLocation { ServerProviderLocation({ required this.title, required this.identifier, + required this.countryDisplayKey, this.description, this.flag = '', }); final String title; final String identifier; + final String countryDisplayKey; final String? description; final String flag; } diff --git a/lib/logic/providers/server_providers/digital_ocean.dart b/lib/logic/providers/server_providers/digital_ocean.dart index c69dfa8c..bd61c4e1 100644 --- a/lib/logic/providers/server_providers/digital_ocean.dart +++ b/lib/logic/providers/server_providers/digital_ocean.dart @@ -438,6 +438,7 @@ class DigitalOceanServerProvider extends ServerProvider { description: rawLocation.name, flag: rawLocation.flag, identifier: rawLocation.slug, + countryDisplayKey: rawLocation.countryDisplayKey, ); } catch (e) { continue; diff --git a/lib/logic/providers/server_providers/hetzner.dart b/lib/logic/providers/server_providers/hetzner.dart index d6e4f1ba..36d0ed6d 100644 --- a/lib/logic/providers/server_providers/hetzner.dart +++ b/lib/logic/providers/server_providers/hetzner.dart @@ -156,6 +156,7 @@ class HetznerServerProvider extends ServerProvider { description: server.location.description, flag: server.location.flag, identifier: server.location.name, + countryDisplayKey: server.location.countryDisplayKey, ), ), ); @@ -456,6 +457,7 @@ class HetznerServerProvider extends ServerProvider { description: rawLocation.description, flag: rawLocation.flag, identifier: rawLocation.name, + countryDisplayKey: rawLocation.countryDisplayKey, ); } catch (e) { continue; diff --git a/lib/ui/pages/setup/initializing/server_type_picker.dart b/lib/ui/pages/setup/initializing/server_type_picker.dart index 6fb09f4b..bdcabe92 100644 --- a/lib/ui/pages/setup/initializing/server_type_picker.dart +++ b/lib/ui/pages/setup/initializing/server_type_picker.dart @@ -120,6 +120,14 @@ class SelectLocationPage extends StatelessWidget { .titleMedium, ), const SizedBox(height: 8), + Text( + location.countryDisplayKey.tr(), + style: Theme.of(context) + .textTheme + .bodyMedium, + ), + if (location.description != null) + const SizedBox(height: 4), if (location.description != null) Text( location.description!,