1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* SonarQube, open source software quality management tool.
* Copyright (C) 2008-2012 SonarSource
* mailto:contact AT sonarsource DOT com
*
* SonarQube is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* SonarQube is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
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;
/**
* {@link I18n}-companion component that provides translation facilities for rule names, descriptions and parameter names.
*
* @since 3.2
*/
public interface RuleI18n extends ServerComponent, BatchComponent {
/**
* Returns the localized name of the rule identified by its repository key and rule key.
* <br>
* 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.
*
* @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, or null
*/
String getName(String repositoryKey, String ruleKey, Locale locale);
/**
* Returns the localized name or the name of the rule.
* <br>
* 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.
* <br>
* 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.
*
* @param repositoryKey the repository key
* @param ruleKey the rule key
* @param locale the locale to translate into
* @return the translated description of the rule, or the default English one if the given locale is not supported
*/
String getDescription(String repositoryKey, String ruleKey, Locale locale);
/**
* Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key.
* <br>
* 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).
*
* @param repositoryKey the repository key
* @param ruleKey the rule key
* @param paramKey the parameter key
* @param locale the locale to translate into
* @return 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.
*/
String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale);
}
|