Browse Source

init collator once

Tobias Hagemann 1 year ago
parent
commit
2a704d5eb4
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/main/java/org/cryptomator/launcher/SupportedLanguages.java

+ 5 - 5
src/main/java/org/cryptomator/launcher/SupportedLanguages.java

@@ -31,11 +31,11 @@ public class SupportedLanguages {
 	public SupportedLanguages(Settings settings) {
 		var preferredLanguage = settings.languageProperty().get();
 		preferredLocale = preferredLanguage == null ? Locale.getDefault() : Locale.forLanguageTag(preferredLanguage);
-		var sorted = LANGUAGE_TAGS.stream().sorted((a, b) -> {
-			var collator = Collator.getInstance(preferredLocale);
-			collator.setStrength(Collator.PRIMARY);
-			return collator.compare(Locale.forLanguageTag(a).getDisplayName(), Locale.forLanguageTag(b).getDisplayName());
-		}).collect(Collectors.toList());
+		var collator = Collator.getInstance(preferredLocale);
+		collator.setStrength(Collator.PRIMARY);
+		var sorted = LANGUAGE_TAGS.stream() //
+				.sorted((a, b) -> collator.compare(Locale.forLanguageTag(a).getDisplayName(), Locale.forLanguageTag(b).getDisplayName())) //
+				.collect(Collectors.toList());
 		sorted.add(0, Settings.DEFAULT_LANGUAGE);
 		sorted.add(1, ENGLISH);
 		sortedLanguageTags = Collections.unmodifiableList(sorted);