From 034013c4aefee3ffbf158caf1489d261ae5bf4b9 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 4 Dec 2012 11:59:12 +0100 Subject: SONARIDE-334 Title is not displayed for some rules RuleI18nManager has now a new method to get the rule name by searching the name in the i18n, and then if not found return the rule name property. --- .../src/main/java/org/sonar/api/i18n/RuleI18n.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'sonar-plugin-api') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java index a2a083a787f..4afdb625394 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/i18n/RuleI18n.java @@ -21,6 +21,7 @@ package org.sonar.api.i18n; import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; +import org.sonar.api.rules.Rule; import java.util.Locale; @@ -35,15 +36,27 @@ public interface RuleI18n extends ServerComponent, BatchComponent { * Returns the localized name of the rule identified by its repository key and rule key. *
* If the name is not found in the given locale, then the default name is returned (the English one). - * As a rule must have a name (this is a constraint in Sonar), this method never returns null. + * This method could return null if no default name found. This is the cause for instance the copies rules. * * @param repositoryKey the repository key * @param ruleKey the rule key * @param locale the locale to translate into - * @return the translated name of the rule, or the default English one if the given locale is not supported + * @return the translated name of the rule, or the default English one if the given locale is not supported, or null */ String getName(String repositoryKey, String ruleKey, Locale locale); + /** + * Returns the localized name or the name of the rule. + *
+ * If the name is not found in the given locale, then the default name is returned (the English one). + * It the default name is not found, then the rule name is returned. + * + * @param rule the rule + * @param locale the locale to translate into + * @return the translated name of the rule, or the default English one if the given locale is not supported, or the rule name. + */ + String getName(Rule rule, Locale locale); + /** * Returns the localized description of the rule identified by its repository key and rule key. *
-- cgit v1.2.3