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; 024import org.sonar.api.rules.Rule; 025 026import java.util.Locale; 027 028/** 029 * {@link I18n}-companion component that provides translation facilities for rule names, descriptions and parameter names. 030 * 031 * @since 3.2 032 */ 033public interface RuleI18n extends ServerComponent, BatchComponent { 034 035 /** 036 * Returns the localized name of the rule identified by its repository key and rule key. 037 * <br> 038 * If the name is not found in the given locale, then the default name is returned (the English one). 039 * This method could return null if no default name found. This is the cause for instance the copies rules. 040 * 041 * @param repositoryKey the repository key 042 * @param ruleKey the rule key 043 * @param locale the locale to translate into 044 * @return the translated name of the rule, or the default English one if the given locale is not supported, or null 045 */ 046 String getName(String repositoryKey, String ruleKey, Locale locale); 047 048 /** 049 * Returns the localized name or the name of the rule. 050 * <br> 051 * If the name is not found in the given locale, then the default name is returned (the English one). 052 * It the default name is not found, then the rule name is returned. 053 * 054 * @param rule the rule 055 * @param locale the locale to translate into 056 * @return the translated name of the rule, or the default English one if the given locale is not supported, or the rule name. 057 */ 058 String getName(Rule rule, Locale locale); 059 060 /** 061 * Returns the localized description of the rule identified by its repository key and rule key. 062 * <br> 063 * If the description is not found in the given locale, then the default description is returned (the English one). 064 * As a rule must have a description (this is a constraint in Sonar), this method never returns null. 065 * 066 * @param repositoryKey the repository key 067 * @param ruleKey the rule key 068 * @param locale the locale to translate into 069 * @return the translated description of the rule, or the default English one if the given locale is not supported 070 */ 071 String getDescription(String repositoryKey, String ruleKey, Locale locale); 072 073 /** 074 * Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key. 075 * <br> 076 * If the name is not found in the given locale, then the English translation is searched and return if found. Otherwise, 077 * this method returns null (= if no translation can be found). 078 * 079 * @param repositoryKey the repository key 080 * @param ruleKey the rule key 081 * @param paramKey the parameter key 082 * @param locale the locale to translate into 083 * @return the translated name of the rule parameter, or the default English one if the given locale is not supported, or null if 084 * no translation can be found. 085 */ 086 String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale); 087 088}