X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2FL10nFilter.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2FL10nFilter.java;h=4d6a7443c1cbabc2ca326b9ec72eb3abef11b513;hb=1127a71127c6488152e5cbe3b8c6d941eaf14e83;hp=0000000000000000000000000000000000000000;hpb=ace61a10afeeeb05ec7ae7facf3d636cd87f3a9b;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java b/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java
new file mode 100644
index 0000000..4d6a744
--- /dev/null
+++ b/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java
@@ -0,0 +1,55 @@
+/*
+ * FreenetSone - L10nFilter.java - Copyright © 2010 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
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.pterodactylus.sone.freenet;
+
+import java.util.Map;
+
+import net.pterodactylus.util.template.DataProvider;
+import net.pterodactylus.util.template.Filter;
+import freenet.l10n.BaseL10n;
+
+/**
+ * {@link Filter} implementation replaces {@link String} values with their
+ * translated equivalents.
+ *
+ * @author David âBombeâ Roden
+ */
+public class L10nFilter implements Filter {
+
+ /** The l10n handler. */
+ private final BaseL10n l10n;
+
+ /**
+ * Creates a new L10n filter.
+ *
+ * @param l10n
+ * The l10n handler
+ */
+ public L10nFilter(BaseL10n l10n) {
+ this.l10n = l10n;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String format(DataProvider dataProvider, Object data, Map parameters) {
+ return l10n.getString(String.valueOf(data));
+ }
+
+}