Skip to content
Snippets Groups Projects
Verified Commit 4ac50d01 authored by Torsten Grote's avatar Torsten Grote
Browse files

Add getCountryDisplayName() method to LocationUtils

parent 487af945
No related branches found
No related tags found
1 merge request!6Add getCountryDisplayName() method to LocationUtils
Pipeline #14561 passed
......@@ -2,6 +2,8 @@ package org.briarproject.onionwrapper;
import org.briarproject.nullsafety.NotNullByDefault;
import java.util.Locale;
@NotNullByDefault
public interface LocationUtils {
......@@ -13,4 +15,20 @@ public interface LocationUtils {
* https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha 2</a>.
*/
String getCurrentCountry();
/**
* Returns the name of the country for display in the UI
* or the isoCode if none could be found.
*
* @param isoCode The result from {@link #getCurrentCountry()}.
*/
static String getCountryDisplayName(String isoCode) {
for (Locale locale : Locale.getAvailableLocales()) {
if (locale.getCountry().equalsIgnoreCase(isoCode)) {
return locale.getDisplayCountry();
}
}
// Name is unknown
return isoCode;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment