org.sonar.api.i18n
Interface RuleI18n

All Superinterfaces:
BatchComponent, ServerComponent

public interface RuleI18n
extends ServerComponent, BatchComponent

I18n-companion component that provides translation facilities for rule names, descriptions and parameter names.

Since:
3.2

Method Summary
 String getDescription(String repositoryKey, String ruleKey, Locale locale)
          Returns the localized description of the rule identified by its repository key and rule key.
 String getName(Rule rule, Locale locale)
          Returns the localized name or the name of the rule.
 String getName(String repositoryKey, String ruleKey, Locale locale)
          Returns the localized name of the rule identified by its repository key and rule key.
 String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale)
          Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key.
 

Method Detail

getName

@CheckForNull
String getName(String repositoryKey,
                            String ruleKey,
                            Locale locale)
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). This method could return null if no default name found. This is the cause for instance the copies rules.

Parameters:
repositoryKey - the repository key
ruleKey - the rule key
locale - the locale to translate into
Returns:
the translated name of the rule, or the default English one if the given locale is not supported, or null

getName

@CheckForNull
String getName(Rule rule,
                            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.

Parameters:
rule - the rule
locale - the locale to translate into
Returns:
the translated name of the rule, or the default English one if the given locale is not supported, or the rule name.

getDescription

String getDescription(String repositoryKey,
                      String ruleKey,
                      Locale locale)
Returns the localized description of the rule identified by its repository key and rule key.
If the description is not found in the given locale, then the default description is returned (the English one). As a rule must have a description (this is a constraint in Sonar), this method never returns null.

Parameters:
repositoryKey - the repository key
ruleKey - the rule key
locale - the locale to translate into
Returns:
the translated description of the rule, or the default English one if the given locale is not supported

getParamDescription

@CheckForNull
String getParamDescription(String repositoryKey,
                                        String ruleKey,
                                        String paramKey,
                                        Locale locale)
Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key.
If the name is not found in the given locale, then the English translation is searched and return if found. Otherwise, this method returns null (= if no translation can be found).

Parameters:
repositoryKey - the repository key
ruleKey - the rule key
paramKey - the parameter key
locale - the locale to translate into
Returns:
the translated name of the rule parameter, or the default English one if the given locale is not supported, or null if no translation can be found.


Copyright © 2009-2013 SonarSource. All Rights Reserved.