How I can localize array?

Hi. I have array

 @State private var countries = ["Australia", "Austria", "Azerbaijan", "Albania", "Algeria", "Anguilla", "Angola", "Andorra", "Antarctic", "Antigua and Barbuda", "Netherlands' An lles", "Argentina", "Armenia", "Aruba", "Afghanistan", "Bahamas", "Bangladesh", "Barbados", "Bahrain", "Belarus", "Belize", "Belgium", "Benin", "Bermuda", "Bouvet Island", "Bulgaria", "Bolivia", "Bosnia & Herzegovina", "Botswana", "Brazil", "Brunei Darussalam", "Burkina‐Faso", "Burundi", "Bhutan", "Vanuatu", "Vatican (Holy See)", "Great Britain (United Kingdom)", "Hungary", "Venezuela", "****** Islands, British", "****** Islands, US", "American Samoa", "East Timor", "Viet Nam", "Gabon", "Haiti", "Guyana", "Gambia", "Ghana", "Guadeloupe", "Guatemala", "Guinea", "Guinea‐Bissau", "Germany", "Gibraltar", "Honduras", "Hong Kong", "Grenada", "Greenland", "Greece", "Georgia", "Guam", "Denmark", "Congo, Democratic Republic of the", "Djibouti", "Dominica", "Dominican Republic", "Egypt", "Zambia", "Western Sahara", "Zimbabwe", "Israel", "India", "Indonesia", "Jordan", "Iraq", "Iran", "Ireland", "Iceland", "Spain", "Italy", "Yemen", "Cape Verde", "Kazakhstan", "Cayman Islands", "Cambodia", "Cameroon", "Canada", "Qatar", "Kenya", "Cyprus", "Kirghizstan", "Kiribati", "China", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Costa Rica", "Cote d'Ivoire", "Cuba", "Kuwait", "Cook Islands", "Lao People's Democratic Republic", "Latvia", "Lesotho", "Liberia", "Lebanon", "Libyan **** Jamahiriya", "Lithuania", "Liechtenstein", "Luxembourg", "Mauritius", "Mauritania", "Madagascar", "Mayotte", "Macau (Macao)", "Macedonia", "Malawi", "Malaysia", "Mali", "Maldives", "Malta", "Marocco", "Martinique", "Marshall Islands", "Mexico", "Federated States of Micronesia", "Mozambique", "Moldova", "Monaco", "Mongolia", "Montserrat", "Myanmar", "Namibia", "Nauru", "Nepal", "Niger", "Nigeria", "Netherlands (Holland)", "Nicaragua", "Niue", "New Zealand", "New Caledonia", "Norway", "Norfolk Island", "United **** Emirates", "Oman", "Pakistan", "Palau", "Pales nian Territory (occupied)", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Reunion", "Christmas Island", "Russia (Russian Federation)", "Rwanda", "Romania", "El Salvador", "Samoa", "San Marino", "Sao Tomea and Principe", "Saudi Arabia", "Swaziland", "Svalbard and Jan Mayen Islands", "St. Helena", "Korea (North)", "Northern Mariana Islands", "Seychelles", "Saint Vincent and the Grenadines", "St. Pierre and Miquelon", "Senegal", "Saint Kitts (Christopher) and Nevis", "Saint Lucia", "Singapore", "Syria", "Slovak Republic", "Slovenia", "United States of America", "Solomon Islands", "Somali", "Sudan", "Surinam", "Sierra Leone", "Tadjikistan", "Thailand", "Taiwan", "Tanzania", "Turks and Caicos Islands", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tuvalu", "Tunisia", "Turkmenistan", "Turkey", "Uganda", "Uzbekistan", "Ukraine", "Wallis and Futuna Islands", "Uruguay", "Faroe Islands", "Fiji", "Philippines", "Finland", "Falkland (Malvinas) Islands", "France", "French Guyana", "French Polynesia", "Heard and McDonald Islands", "Croatia", "Central African Republic", "Chad", "Czech Republic", "Chili", "Switzerland", "Sweden", "Sri Lanka", "Ecuador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Yugoslavia", "South Africa", "South Georgia and the South Sandwich Islands", "Korea (South)", "Jamaica", "Japan", "French Southern Territories", "British Indian Ocean Territory", "United States Minor Outlying Islands"]


I need translate this array. "Afghanistan" = "Афганистан"; don't work. Tell me who knows. Maybe I missed something?

It's better to use a method like https://developer.apple.com/documentation/foundation/locale/2293396-localizedstring to get the localized names of regions.

Could you explain what you want ? Get each country in its local ?

  • "Afghanistan" -> "Афганистан"
  • "Greece" -> "Ελλάδα"

how did you get this array which is not in alphabetical order ?

I have a little flag guessing game. All countries are stored in an array and 3 pieces are selected at random.

A method for obtaining localized region names will not work.

Can someone help. At the place where the array is called, add NSLocalizedString. Here is my example Text(NSLocalizedString(countries[correctAnswer], comment: "") )

How I can localize array?
 
 
Q