From bc917088bfb0fdc18e8c606a224e099bfaace5c2 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 21 Dec 2017 12:48:29 +0300 Subject: [PATCH] properties: do not add redundant "_" to suffix --- .../com/intellij/lang/properties/PropertiesUtil.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java index 2f90e88e033d..a910caaf60b9 100644 --- a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java +++ b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/PropertiesUtil.java @@ -152,7 +152,16 @@ public class PropertiesUtil { final String language = splitRawLocale[1]; final String country = splitRawLocale.length > 2 ? splitRawLocale[2] : ""; final String variant = splitRawLocale.length > 3 ? splitRawLocale[3] : ""; - return Pair.create(new Locale(language, country, variant), language + "_" + country + "_" + variant); + + StringBuilder trimmedSuffix = new StringBuilder(language); + if (!country.isEmpty()) { + trimmedSuffix.append("_").append(country); + } + if (!variant.isEmpty()) { + trimmedSuffix.append("_").append(variant); + } + + return Pair.create(new Locale(language, country, variant), trimmedSuffix.toString()); } } return Pair.create(DEFAULT_LOCALE, "");