X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FUnknownDateFilter.java;h=2d6c05c8c098f8ece7fee155f5e13c80f6b1dcf9;hb=ecfd4c5a91d204ce4c001d19fa600cf42ac4cf43;hp=7981d55f3e980528e6e39d6fc2db8e20b463501d;hpb=1e9a08c2b73b16dc178437eb8c8025aaa083fcca;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java b/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java
index 7981d55..2d6c05c 100644
--- a/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java
+++ b/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java
@@ -1,5 +1,5 @@
/*
- * Sone - UnknownDateFilter.java - Copyright © 2011â2015 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
@@ -19,20 +19,18 @@ package net.pterodactylus.sone.template;
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 David âBombeâ Roden
+ * {@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;
@@ -40,13 +38,11 @@ public class UnknownDateFilter implements Filter {
/**
* 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;
}
@@ -57,7 +53,7 @@ public class UnknownDateFilter implements Filter {
public Object format(TemplateContext templateContext, Object data, Map parameters) {
if (data instanceof Long) {
if ((Long) data == 0) {
- return l10nHandler.getString(unknownKey);
+ return translation.translate(unknownKey);
}
}
return data;