You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RuleI18n.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.api.i18n;
  21. import java.util.Locale;
  22. import javax.annotation.CheckForNull;
  23. import org.sonar.api.ce.ComputeEngineSide;
  24. import org.sonar.api.rules.Rule;
  25. import org.sonar.api.server.ServerSide;
  26. /**
  27. * {@link I18n}-companion component that provides translation facilities for rule names, descriptions and parameter names.
  28. *
  29. * @since 3.2
  30. * @deprecated in 4.1. Rules are not localized anymore. See http://jira.sonarsource.com/browse/SONAR-4885
  31. */
  32. @Deprecated
  33. @ServerSide
  34. @ComputeEngineSide
  35. public interface RuleI18n {
  36. /**
  37. * Returns the localized name of the rule identified by its repository key and rule key.
  38. * <br>
  39. * If the name is not found in the given locale, then the default name is returned (the English one).
  40. * This method could return null if no default name found. This is the cause for instance the copies rules.
  41. *
  42. * @param repositoryKey the repository key
  43. * @param ruleKey the rule key
  44. * @param locale not used
  45. * @return the translated name of the rule, or the default English one if the given locale is not supported, or null
  46. * @deprecated since 4.1. Rules are not localized anymore. See http://jira.sonarsource.com/browse/SONAR-4885
  47. */
  48. @Deprecated
  49. @CheckForNull
  50. String getName(String repositoryKey, String ruleKey, Locale locale);
  51. /**
  52. * Returns the name of the rule identified by its repository key and rule key.
  53. * <br>
  54. * This method could return null if no default name found. This is the cause for instance the copies rules.
  55. *
  56. * @param repositoryKey the repository key
  57. * @param ruleKey the rule key
  58. * @return the nullable name of the rule
  59. * @since 4.1
  60. */
  61. @CheckForNull
  62. String getName(String repositoryKey, String ruleKey);
  63. /**
  64. * Returns the localized name or the name of the rule.
  65. * <br>
  66. * If the name is not found in the given locale, then the default name is returned (the English one).
  67. * It the default name is not found, then the rule name is returned.
  68. *
  69. * @param rule the rule
  70. * @param locale the locale to translate into
  71. * @return the translated name of the rule, or the default English one if the given locale is not supported, or the rule name.
  72. * @deprecated since 4.1. Rules are not localized anymore. See http://jira.sonarsource.com/browse/SONAR-4885
  73. */
  74. @Deprecated
  75. @CheckForNull
  76. String getName(Rule rule, Locale locale);
  77. /**
  78. * Returns the name of the rule.
  79. * <br>
  80. * It the default name is not found, then the rule name is returned.
  81. *
  82. * @param rule the rule
  83. * @return the nullable name of the rule
  84. * @since 4.1
  85. */
  86. @CheckForNull
  87. String getName(Rule rule);
  88. /**
  89. * Returns the localized description of the rule identified by its repository key and rule key.
  90. * <br>
  91. * If the description is not found in the given locale, then the default description is returned (the English one).
  92. * As a rule must have a description (this is a constraint in Sonar), this method never returns null.
  93. *
  94. * @param repositoryKey the repository key
  95. * @param ruleKey the rule key
  96. * @param locale the locale to translate into
  97. * @return the translated description of the rule, or the default English one if the given locale is not supported
  98. * @deprecated since 4.1. Rules are not localized anymore. See http://jira.sonarsource.com/browse/SONAR-4885
  99. */
  100. @Deprecated
  101. String getDescription(String repositoryKey, String ruleKey, Locale locale);
  102. /**
  103. * Returns the description of the rule identified by its repository key and rule key.
  104. * <br>
  105. * As a rule must have a description (this is a constraint in SonarQube), this method never returns null.
  106. *
  107. * @param repositoryKey the repository key
  108. * @param ruleKey the rule key
  109. * @return the description of the rule
  110. * @since 4.1
  111. */
  112. String getDescription(String repositoryKey, String ruleKey);
  113. /**
  114. * Returns the localized name of the rule parameter identified by the rules's key and repository key, and by the parameter key.
  115. * <br>
  116. * If the name is not found in the given locale, then the English translation is searched and return if found. Otherwise,
  117. * this method returns null (= if no translation can be found).
  118. *
  119. * @param repositoryKey the repository key
  120. * @param ruleKey the rule key
  121. * @param paramKey the parameter key
  122. * @param locale the locale to translate into
  123. * @return the translated name of the rule parameter, or the default English one if the given locale is not supported, or null if
  124. * no translation can be found.
  125. * @deprecated since 4.1. Rules are not localized anymore. See http://jira.sonarsource.com/browse/SONAR-4885
  126. */
  127. @Deprecated
  128. @CheckForNull
  129. String getParamDescription(String repositoryKey, String ruleKey, String paramKey, Locale locale);
  130. /**
  131. * Returns the name of the rule parameter identified by the rules's key and repository key, and by the parameter key.
  132. *
  133. * @param repositoryKey the repository key
  134. * @param ruleKey the rule key
  135. * @param paramKey the parameter key
  136. * @return the nullable name of the rule parameter
  137. * @since 4.1
  138. */
  139. @CheckForNull
  140. String getParamDescription(String repositoryKey, String ruleKey, String paramKey);
  141. }