aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java8
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java1
2 files changed, 8 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
index 42a1707e182..ae746c6580b 100644
--- a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
+++ b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java
@@ -226,8 +226,14 @@ public class DefaultI18n implements I18n, Startable {
return propertyToBundles.keySet();
}
+ public Locale getEffectiveLocale(Locale locale) {
+ Locale bundleLocale = ResourceBundle.getBundle(BUNDLE_PACKAGE + "core", locale, this.classloader, this.control).getLocale();
+ locale.getISO3Language();
+ return bundleLocale.getLanguage().isEmpty() ? Locale.ENGLISH : bundleLocale;
+ }
+
@CheckForNull
- private String formatMessage(@Nullable String message, Object... parameters) {
+ private static String formatMessage(@Nullable String message, Object... parameters) {
if (message == null || parameters.length == 0) {
return message;
}
diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
index 409d7d94eaf..985810e8cb6 100644
--- a/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/i18n/DefaultI18nTest.java
@@ -145,6 +145,7 @@ public class DefaultI18nTest {
assertThat(underTest.message(Locale.CHINA, "checkstyle.rule1.name", null)).isEqualTo("Rule one");
assertThat(underTest.message(Locale.CHINA, "any", null)).isEqualTo("Any");
assertThat(underTest.message(Locale.CHINA, "sqale.page", null)).isEqualTo("Sqale page title");
+ assertThat(underTest.getEffectiveLocale(Locale.CHINA)).isEqualTo(Locale.ENGLISH);
}
@Test