001/* 002 * SonarQube, open source software quality management tool. 003 * Copyright (C) 2008-2013 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * SonarQube is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * SonarQube is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api.i18n; 021 022import org.sonar.api.BatchComponent; 023import org.sonar.api.ServerComponent; 024import org.sonar.api.rules.Rule; 025 026import javax.annotation.CheckForNull; 027 028import java.util.Locale; 029 030/** 031 * {@link I18n}-companion component that provides translation facilities for rule names, descriptions and parameter names. 032 * 033 * @since 3.2 034 */ 035public interface RuleI18n extends ServerComponent, BatchComponent { 036 037 /** 038 * Returns the localized name of the rule identified by its repository key and rule key. 039 * <br> 040 * If the name is not found in the given locale, then the default name is returned (the English one). 041 * This method could return null if no default name found. This is the cause for instance the copies rules. 042 * 043 * @param repositoryKey the repository key 044 * @param ruleKey the rule key 045 * @param locale not used 046 * @return the translated name of the rule, or the default English one if the given locale is not supported, or null 047 * @deprecated since 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 048 */ 049 @Deprecated 050 @CheckForNull 051 String getName(String repositoryKey, String ruleKey, Locale locale); 052 053 /** 054 * Returns the name of the rule identified by its repository key and rule key. 055 * <br> 056 * This method could return null if no default name found. This is the cause for instance the copies rules. 057 * 058 * @param repositoryKey the repository key 059 * @param ruleKey the rule key 060 * @return the nullable name of the rule 061 * @since 4.1 062 */ 063 @CheckForNull 064 String getName(String repositoryKey, String ruleKey); 065 066 /** 067 * Returns the localized name or the name of the rule. 068 * <br> 069 * If the name is not found in the given locale, then the default name is returned (the English one). 070 * It the default name is not found, then the rule name is returned. 071 * 072 * @param rule the rule 073 * @param locale the locale to translate into 074 * @return the translated name of the rule, or the default English one if the given locale is not supported, or the rule name. 075 * @deprecated since 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 076 */ 077 @Deprecated 078 @CheckForNull 079 String getName(Rule rule, Locale locale); 080 081 /** 082 * Returns the name of the rule. 083 * <br> 084 * It the default name is not found, then the rule name is returned. 085 * 086 * @param rule the rule 087 * @return the nullable name of the rule 088 * @since 4.1 089 */ 090 @CheckForNull 091 String getName(Rule rule); 092 093 /** 094 * Returns the localized description of the rule identified by its repository key and rule key. 095 * <br> 096 * If the description is not found in the given locale, then the default description is returned (the English one). 097 * As a rule must have a description (this is a constraint in Sonar), this method never returns null. 098 * 099 * @param repositoryKey the repository key 100 * @param ruleKey the rule key 101 * @param locale the locale to translate into 102 * @return the translated description of the rule, or the default English one if the given locale is not supported 103 * @deprecated since 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 104 */ 105 @Deprecated 106 String getDescription(String repositoryKey, String ruleKey, Locale locale); 107 108 /** 109 * Returns the description of the rule identified by its repository key and rule key. 110 * <br> 111 * As a rule must have a description (this is a constraint in SonarQube), this method never returns null. 112 * 113 * @param repositoryKey the repository key 114 * @param ruleKey the rule key 115 * @return the description of the rule 116 * @since 4.1 117 */ 118 String getDescription(String repositoryKey, String ruleKey); 119 120 /** 121 * Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key. 122 * <br> 123 * If the name is not found in the given locale, then the English translation is searched and return if found. Otherwise, 124 * this method returns null (= if no translation can be found). 125 * 126 * @param repositoryKey the repository key 127 * @param ruleKey the rule key 128 * @param paramKey the parameter key 129 * @param locale the locale to translate into 130 * @return the translated name of the rule parameter, or the default English one if the given locale is not supported, or null if 131 * no translation can be found. 132 * @deprecated since 4.1. Rules are not localized anymore. See http://jira.codehaus.org/browse/SONAR-4885 133 */ 134 @Deprecated 135 @CheckForNull 136 String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale); 137 138 /** 139 * Returns the name of the rule parameter identified by the rules's key and repository key, and by the parameter key. 140 * 141 * @param repositoryKey the repository key 142 * @param ruleKey the rule key 143 * @param paramKey the parameter key 144 * @return the nullable name of the rule parameter 145 * @since 4.1 146 */ 147 @CheckForNull 148 String getParamDescription(String repositoryKey, String ruleKey, String paramKey); 149 150}