aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-11-29 12:05:54 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-11-29 12:06:18 +0100
commit2f4e11fb0c0bd16ccb2d8c35292df3a86d879778 (patch)
tree07159b1e7f10d1d1046762a0d293e983f305314b /sonar-server
parente820ac79c6365cf3b86d9a028cddeba64657db94 (diff)
downloadsonarqube-2f4e11fb0c0bd16ccb2d8c35292df3a86d879778.tar.gz
sonarqube-2f4e11fb0c0bd16ccb2d8c35292df3a86d879778.zip
SONAR-4885 Stop supporting the internationalization of rule descriptions and titles
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java16
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb38
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java18
6 files changed, 29 insertions, 67 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java b/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java
index 906fb41ee80..9b64b61a573 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RubyRuleService.java
@@ -49,7 +49,7 @@ public class RubyRuleService implements ServerComponent, Startable {
@CheckForNull
public String ruleL10nName(Rule rule) {
- String name = i18n.getName(rule.getRepositoryKey(), rule.getKey(), UserSession.get().locale());
+ String name = i18n.getName(rule.getRepositoryKey(), rule.getKey());
if (name == null) {
name = rule.getName();
}
@@ -57,7 +57,7 @@ public class RubyRuleService implements ServerComponent, Startable {
}
public String ruleL10nDescription(Rule rule) {
- String desc = i18n.getDescription(rule.getRepositoryKey(), rule.getKey(), UserSession.get().locale());
+ String desc = i18n.getDescription(rule.getRepositoryKey(), rule.getKey());
if (desc == null) {
desc = rule.getDescription();
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
index e2333386845..26b17f67dc8 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
@@ -406,20 +406,16 @@ public final class JRubyFacade {
return getJRubyI18n().message(rubyLocale, key, defaultValue, parameters);
}
- public String getRuleName(String rubyLocale, String repositoryKey, String key) {
- return getJRubyI18n().getRuleName(rubyLocale, repositoryKey, key);
+ public String getRuleName(String repositoryKey, String key) {
+ return getJRubyI18n().getRuleName(repositoryKey, key);
}
- public String getRuleDescription(String rubyLocale, String repositoryKey, String key) {
- return getJRubyI18n().getRuleDescription(rubyLocale, repositoryKey, key);
+ public String getRuleDescription(String repositoryKey, String key) {
+ return getJRubyI18n().getRuleDescription(repositoryKey, key);
}
- public String getRuleParamDescription(String rubyLocale, String repositoryKey, String key, String paramKey) {
- return getJRubyI18n().getRuleParamDescription(rubyLocale, repositoryKey, key, paramKey);
- }
-
- public List<RuleI18nManager.RuleKey> searchRuleName(String rubyLocale, String searchText) {
- return getJRubyI18n().searchRuleName(rubyLocale, searchText);
+ public String getRuleParamDescription(String repositoryKey, String key, String paramKey) {
+ return getJRubyI18n().getRuleParamDescription(repositoryKey, key, paramKey);
}
public String getJsL10nDictionnary(String rubyLocale) {
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java
index e7c23466210..2460ad039e9 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyI18n.java
@@ -79,20 +79,16 @@ public class JRubyI18n implements ServerComponent {
return StringUtils.defaultString(i18n.message(getLocale(rubyLocale), key, defaultValue, parameters), key);
}
- public String getRuleName(String rubyLocale, String repositoryKey, String key) {
- return ruleI18nManager.getName(repositoryKey, key, toLocale(rubyLocale));
+ public String getRuleName(String repositoryKey, String key) {
+ return ruleI18nManager.getName(repositoryKey, key);
}
- public String getRuleDescription(String rubyLocale, String repositoryKey, String key) {
- return ruleI18nManager.getDescription(repositoryKey, key, toLocale(rubyLocale));
+ public String getRuleDescription(String repositoryKey, String key) {
+ return ruleI18nManager.getDescription(repositoryKey, key);
}
- public String getRuleParamDescription(String rubyLocale, String repositoryKey, String ruleKey, String paramKey) {
- return ruleI18nManager.getParamDescription(repositoryKey, ruleKey, paramKey, toLocale(rubyLocale));
- }
-
- public List<RuleI18nManager.RuleKey> searchRuleName(String rubyLocale, String searchText) {
- return ruleI18nManager.searchNames(searchText, toLocale(rubyLocale));
+ public String getRuleParamDescription(String repositoryKey, String ruleKey, String paramKey) {
+ return ruleI18nManager.getParamDescription(repositoryKey, ruleKey, paramKey);
}
public String getJsDictionnary(String rubyLocale) {
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
index e12043ab117..b4c8d27a0d9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule.rb
@@ -111,29 +111,17 @@ class Rule < ActiveRecord::Base
name.downcase<=>other.name.downcase
end
- def name(l10n=true)
- if l10n
- @l10n_name ||=
- begin
- result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleName(I18n.locale, repository_key, plugin_rule_key)
- result = read_attribute(:name) unless result
- # SONAR-4583
- # name should return an empty string instead of nil
- result = '' unless result
- result
- end
- else
- @raw_name ||=
- begin
- result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleName("en", repository_key, plugin_rule_key)
- # if no name present in the bundle, try to find it in the DB
- result = read_attribute(:name) unless result
- # SONAR-4583
- # name should return an empty string instead of nil
- result = '' unless result
- result
- end
- end
+ def name(unused_deprecated_l10n=true)
+ @raw_name ||=
+ begin
+ result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleName(repository_key, plugin_rule_key)
+ # if no name present in the bundle, try to find it in the DB
+ result = read_attribute(:name) unless result
+ # SONAR-4583
+ # name should return an empty string instead of nil
+ result = '' unless result
+ result
+ end
end
def name=(value)
@@ -141,9 +129,9 @@ class Rule < ActiveRecord::Base
end
def description
- @l10n_description ||=
+ @raw_description ||=
begin
- result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleDescription(I18n.locale, repository_key, plugin_rule_key)
+ result = Java::OrgSonarServerUi::JRubyFacade.getInstance().getRuleDescription(repository_key, plugin_rule_key)
result = read_attribute(:description) unless result
# SONAR-4583
# description should return an empty string instead of nil
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb
index b45ae01b437..0017ae761bf 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rules_parameter.rb
@@ -34,9 +34,9 @@ class RulesParameter < ActiveRecord::Base
end
def description
- @l10n_description ||=
+ @raw_description ||=
begin
- result = Java::OrgSonarServerUi::JRubyFacade.instance.getRuleParamDescription(I18n.locale, rule.repository_key, rule.plugin_rule_key, name)
+ result = Java::OrgSonarServerUi::JRubyFacade.instance.getRuleParamDescription(rule.repository_key, rule.plugin_rule_key, name)
result = read_attribute(:description) unless result
result
end
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java
index 6923d26f9e7..153b2a74ed6 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RubyRuleServiceTest.java
@@ -41,15 +41,6 @@ public class RubyRuleServiceTest {
RubyRuleService facade = new RubyRuleService(i18n, ruleRegistry);
@Test
- public void should_get_localized_rule_name() {
- MockUserSession.set().setLocale(Locale.FRENCH);
- when(i18n.getName("squid", "AvoidCycle", Locale.FRENCH)).thenReturn("Eviter les cycles");
-
- String name = facade.ruleL10nName(new Rule("squid", "AvoidCycle"));
- assertThat(name).isEqualTo("Eviter les cycles");
- }
-
- @Test
public void should_get_raw_name_if_no_l10n_name() throws Exception {
MockUserSession.set().setLocale(Locale.FRENCH);
when(i18n.getName("squid", "AvoidCycle", Locale.FRENCH)).thenReturn(null);
@@ -61,15 +52,6 @@ public class RubyRuleServiceTest {
}
@Test
- public void should_get_localized_rule_description() {
- MockUserSession.set().setLocale(Locale.FRENCH);
- when(i18n.getDescription("squid", "AvoidCycle", Locale.FRENCH)).thenReturn("Les cycles sont le mal");
-
- String desc = facade.ruleL10nDescription(new Rule("squid", "AvoidCycle"));
- assertThat(desc).isEqualTo("Les cycles sont le mal");
- }
-
- @Test
public void should_get_raw_description_if_no_l10n_description() throws Exception {
MockUserSession.set().setLocale(Locale.FRENCH);
when(i18n.getDescription("squid", "AvoidCycle", Locale.FRENCH)).thenReturn(null);