001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar 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 * Sonar 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 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020package org.sonar.api.i18n; 021 022import org.sonar.api.BatchComponent; 023import org.sonar.api.ServerComponent; 024 025import java.util.Locale; 026 027/** 028 * {@link I18n}-companion component that provides translation facilities for rule names, descriptions and parameter names. 029 * 030 * @since 3.2 031 */ 032public interface RuleI18n extends ServerComponent, BatchComponent { 033 034 /** 035 * Returns the localized name of the rule identified by its repository key and rule key. 036 * <br> 037 * If the name is not found in the given locale, then the default name is returned (the English one). 038 * As a rule must have a name (this is a constraint in Sonar), this method never returns null. 039 * 040 * @param repositoryKey the repository key 041 * @param ruleKey the rule key 042 * @param locale the locale to translate into 043 * @return the translated name of the rule, or the default English one if the given locale is not supported 044 */ 045 String getName(String repositoryKey, String ruleKey, Locale locale); 046 047 /** 048 * Returns the localized description of the rule identified by its repository key and rule key. 049 * <br> 050 * If the description is not found in the given locale, then the default description is returned (the English one). 051 * As a rule must have a description (this is a constraint in Sonar), this method never returns null. 052 * 053 * @param repositoryKey the repository key 054 * @param ruleKey the rule key 055 * @param locale the locale to translate into 056 * @return the translated description of the rule, or the default English one if the given locale is not supported 057 */ 058 String getDescription(String repositoryKey, String ruleKey, Locale locale); 059 060 /** 061 * Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key. 062 * <br> 063 * If the name is not found in the given locale, then the English translation is searched and return if found. Otherwise, 064 * this method returns null (= if no translation can be found). 065 * 066 * @param repositoryKey the repository key 067 * @param ruleKey the rule key 068 * @param paramKey the parameter key 069 * @param locale the locale to translate into 070 * @return the translated name of the rule parameter, or the default English one if the given locale is not supported, or null if 071 * no translation can be found. 072 */ 073 String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale); 074 075}