I want to get a list of all languages that have a different language, where the ISO3 code is used to identify the Locale language. I thought the following should work
class ISO3LangComparator implements Comparator<Locale> {
int compare(Locale locale1, Locale locale2) {
locale1.ISO3Language <=> locale2.ISO3Language
}
}
def allLocales = Locale.getAvailableLocales().toList()
def uniqueLocales = allLocales.unique {new ISO3LangComparator()}
def arabicLocaleCount = uniqueLocales.findAll {it.ISO3Language == 'ara'}.size()
assert arabicLocaleCount <= 1
Dónal source
share