/*
- * Sone - UnknownDateFilter.java - Copyright © 2011 David Roden
+ * Sone - UnknownDateFilter.java - Copyright © 2011–2020 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import java.util.Map;
+import net.pterodactylus.sone.freenet.Translation;
import net.pterodactylus.util.template.Filter;
import net.pterodactylus.util.template.TemplateContext;
-import freenet.l10n.BaseL10n;
/**
* {@link Filter} implementation that replaces a {@link Long} with a value of
- * {@code 0} by a {@link String} from an {@link BaseL10n l10n handler}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ * {@code 0} by a {@link String} from a {@link Translation translation}.
*/
public class UnknownDateFilter implements Filter {
- /** The l10n handler. */
- private BaseL10n l10nHandler;
+ /** The translation. */
+ private final Translation translation;
/** The key for the text to show. */
private final String unknownKey;
/**
* Creates a new unknown date filter.
*
- * @param l10nHandler
- * The l10n handler
- * @param unknownKey
- * The key of the text to show
+ * @param translation The translation
+ * @param unknownKey The key of the text to show
*/
- public UnknownDateFilter(BaseL10n l10nHandler, String unknownKey) {
- this.l10nHandler = l10nHandler;
+ public UnknownDateFilter(Translation translation, String unknownKey) {
+ this.translation = translation;
this.unknownKey = unknownKey;
}
* {@inheritDoc}
*/
@Override
- public Object format(TemplateContext templateContext, Object data, Map<String, String> parameters) {
+ public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
if (data instanceof Long) {
if ((Long) data == 0) {
- return l10nHandler.getString(unknownKey);
+ return translation.translate(unknownKey);
}
}
return data;