diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2019-05-27 17:16:40 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-05-29 20:21:13 +0200 |
commit | 8a6f82e51442fd43274741fd364a486379ab6422 (patch) | |
tree | 0b3da646fc30dbf6735962148cdad0929eaeaee5 /sonar-core | |
parent | bce7a89a9dc2001fb20c0bf06a486b9b82101ed5 (diff) | |
download | sonarqube-8a6f82e51442fd43274741fd364a486379ab6422.tar.gz sonarqube-8a6f82e51442fd43274741fd364a486379ab6422.zip |
SONAR-9898 Deprecate org.sonar.api.i18n.I18n
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java | 1 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/i18n/I18n.java | 121 |
2 files changed, 121 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java index 5fa2df5d720..4b9601f164a 100644 --- a/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java +++ b/sonar-core/src/main/java/org/sonar/core/i18n/DefaultI18n.java @@ -41,7 +41,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.io.IOUtils; import org.picocontainer.Startable; -import org.sonar.api.i18n.I18n; import org.sonar.api.utils.SonarException; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; diff --git a/sonar-core/src/main/java/org/sonar/core/i18n/I18n.java b/sonar-core/src/main/java/org/sonar/core/i18n/I18n.java new file mode 100644 index 00000000000..5616f99e0cf --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/i18n/I18n.java @@ -0,0 +1,121 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.i18n; + +import java.util.Date; +import java.util.Locale; +import javax.annotation.Nullable; +import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.server.ServerSide; + +@ServerSide +@ComputeEngineSide +public interface I18n extends org.sonar.api.i18n.I18n { + + /** + * Searches the message of the <code>key</code> for the <code>locale</code> in the list of available bundles. + * <br> + * If not found in any bundle, <code>defaultValue</code> is returned. + * <br> + * If additional parameters are given (in the objects list), the result is used as a message pattern + * to use in a MessageFormat object along with the given parameters. + * + * @param locale the locale to translate into + * @param key the key of the pattern to translate + * @param defaultValue the default pattern returned when the key is not found in any bundle + * @param parameters the parameters used to format the message from the translated pattern. + * @return the message formatted with the translated pattern and the given parameters + */ + String message(final Locale locale, final String key, @Nullable final String defaultValue, final Object... parameters); + + /** + * Return the distance in time for a duration in milliseconds. + * <br> + * Examples : + * <ul> + * <li>age(Locale.ENGLISH, 1000) -> less than a minute</li> + * <li>age(Locale.ENGLISH, 60000) -> about a minute</li> + * <li>age(Locale.ENGLISH, 120000) -> 2 minutes</li> + * <li>age(Locale.ENGLISH, 3600000) -> about an hour</li> + * <li>age(Locale.ENGLISH, 7200000) -> 2 hours</li> + * <li>age(Locale.ENGLISH, 86400000) -> a day</li> + * <li>age(Locale.ENGLISH, 172800000) -> 2 days</li> + * </ul> + * + * @since 4.2 + */ + String age(Locale locale, long durationInMillis); + + /** + * Return the distance in time between two dates. + * + * @see I18n#age(java.util.Locale, long durationInMillis) + * @since 4.2 + */ + String age(Locale locale, Date fromDate, Date toDate); + + /** + * Reports the distance in time a date and now. + * + * @see I18n#age(java.util.Locale, java.util.Date, java.util.Date) + * @since 4.2 + */ + String ageFromNow(Locale locale, Date date); + + /** + * Return the formatted datetime. + * <p> + * Example: {@code formatDateTime(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22T19:10:03+0100"))} + * returns {@code "Jan 22, 2014 7:10 PM"}. + * </p> + * + * @since 4.2 + */ + String formatDateTime(Locale locale, Date date); + + /** + * Return the formatted date. + * <br> + * Example: {@code formatDateTime(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22"))} + * returns {@code "Jan 22, 2014"}. + * + * @since 4.2 + */ + String formatDate(Locale locale, Date date); + + /** + * Return the formatted decimal, with always one fraction digit. + * <br> + * Example: {@code formatDouble(Locale.FRENCH, 10.56)} returns {@code "10,6"}. + * + * @since 4.4 + */ + String formatDouble(Locale locale, Double value); + + /** + * Return the formatted integer. + * <br> + * Example: {@code formatInteger(Locale.ENGLISH, 100000)} returns {@code "100,000"}. + * + * @since 4.4 + */ + String formatInteger(Locale locale, Integer value); + +} |