All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.api.i18n.I18n Maven / Gradle / Ivy

The newest version!
/*
 * SonarQube
 * Copyright (C) 2009-2022 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.api.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;

/**
 * Main component that provides translation facilities.
 *
 * @since 2.10
 * @deprecated since 7.8 as plugins have no reason to use it anymore
 */
@ServerSide
@ComputeEngineSide
@Deprecated
public interface I18n {

  /**
   * Searches the message of the key for the locale in the list of available bundles.
   * 
* If not found in any bundle, defaultValue is returned. *
* 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. *
* Examples : *
    *
  • age(Locale.ENGLISH, 1000) -> less than a minute
  • *
  • age(Locale.ENGLISH, 60000) -> about a minute
  • *
  • age(Locale.ENGLISH, 120000) -> 2 minutes
  • *
  • age(Locale.ENGLISH, 3600000) -> about an hour
  • *
  • age(Locale.ENGLISH, 7200000) -> 2 hours
  • *
  • age(Locale.ENGLISH, 86400000) -> a day
  • *
  • age(Locale.ENGLISH, 172800000) -> 2 days
  • *
* * @since 4.2 */ String age(Locale locale, long durationInMillis); /** * Return the distance in time between two dates. * * @see I18n#age(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(Locale, Date, Date) * @since 4.2 */ String ageFromNow(Locale locale, Date date); /** * Return the formatted datetime. *

* Example: {@code formatDateTime(Locale.ENGLISH, DateUtils.parseDateTime("2014-01-22T19:10:03+0100"))} * returns {@code "Jan 22, 2014 7:10 PM"}. *

* * @since 4.2 */ String formatDateTime(Locale locale, Date date); /** * Return the formatted date. *
* 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. *
* Example: {@code formatDouble(Locale.FRENCH, 10.56)} returns {@code "10,6"}. * * @since 4.4 */ String formatDouble(Locale locale, Double value); /** * Return the formatted integer. *
* Example: {@code formatInteger(Locale.ENGLISH, 100000)} returns {@code "100,000"}. * * @since 4.4 */ String formatInteger(Locale locale, Integer value); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy