Commit d990e19d authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Easy i18n of stats

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3954 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3377f1ba
/**
* $RCSfile $
* $Revision $
* $Date $
*
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.wildfire.stats;
import org.jivesoftware.util.LocaleUtils;
/**
* A convience class to build statistic parameters out of a resource bundle.
*
* @author Alexander Wenckus
*/
public abstract class i18nStatistic implements Statistic {
private String resourceKey;
private String pluginName;
private Type statisticType;
public i18nStatistic(String resourceKey, Statistic.Type statisticType) {
this(resourceKey, null, statisticType);
}
public i18nStatistic(String resourceKey, String pluginName, Statistic.Type statisticType) {
this.resourceKey = resourceKey;
this.pluginName = pluginName;
this.statisticType = statisticType;
}
public final String getName() {
return retrieveValue("name");
}
public final Type getStatType() {
return statisticType;
}
public final String getDescription() {
return retrieveValue("desc");
}
public final String getUnits() {
return retrieveValue("units");
}
private String retrieveValue(String key) {
String wholeKey = "stat." + resourceKey + "." + key;
if(pluginName != null) {
return LocaleUtils.getLocalizedString(wholeKey, pluginName);
}
else {
return LocaleUtils.getLocalizedString(wholeKey);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment