/*-
 *  Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
 * 
 *  This file is part of CityDoctor2.
 *
 *  CityDoctor2 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.
 *
 *  CityDoctor2 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 CityDoctor2.  If not, see <https://www.gnu.org/licenses/>.
 */
package de.hft.stuttgart.citydoctor2;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Provides access to message strings in different languages.
 * 
 * @author Matthias Betz - 12bema1bif@hft-stuttgart.de
 * @version 1.0
 *
 */
public class CDVMessages {

	public static final String MISSING_SOURCE_FILE = "ArgumentParser.MissingSourceFile";
	public static final String INVALID_PARAMETER = "ArgumentParser.InvalidParameter";
	public static final String VERSION = "CityDoctorValidation.Version";

	private static final String BUNDLE_NAME = "de.hft.stuttgart.citydoctor2.cdvmessages";

	private static final ResourceBundle RESOURCE_BUNDLE;

	static {
		RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, Locale.getDefault());
	}

	/**
	 * Gives the message string for the given key based on the default locale.
	 * 
	 * @param key
	 *            the key for the message
	 * @return localized message.
	 */
	public static String getString(String key) {
		return RESOURCE_BUNDLE.getString(key);
	}

	/**
	 * Constructs a string out of the key and the given parameters with the
	 * MessageFormatter.
	 * 
	 * @param key
	 *            the key for the message
	 * @param params
	 *            the parameters for the message
	 * @return the localized message with the parameters substituted.
	 * @see MessageFormat#format(String, Object...);
	 */
	public static String getString(String key, Object... params) {
		String msg = getString(key);
		return MessageFormat.format(msg, params);
	}

	private CDVMessages() {
	}

}
