📄 Update filenames in file headers
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / freenet / L10nFilter.kt
index 4b0d90f..65ccbb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - L10nFilter.java - Copyright Â© 2010–2019 David Roden
+ * Sone - L10nFilter.kt - Copyright Â© 2010–2019 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
 
 package net.pterodactylus.sone.freenet
 
-import freenet.l10n.*
 import net.pterodactylus.util.template.*
 import java.text.*
-import java.util.*
 
 /**
  * [Filter] implementation replaces [String] values with their
  * translated equivalents.
  */
-class L10nFilter(private val l10n: BaseL10n) : Filter {
+class L10nFilter(private val translation: Translation) : Filter {
 
        override fun format(templateContext: TemplateContext?, data: Any?, parameters: Map<String, Any>?): String {
                val parameterValues = getParameters(data, parameters)
                val text = getText(data)
                return if (parameterValues.isEmpty()) {
-                       l10n.getString(text)
+                       translation.translate(text)
                } else
-                       MessageFormat(l10n.getString(text), Locale(l10n.selectedLanguage.shortCode)).format(parameterValues.toTypedArray())
+                       MessageFormat(translation.translate(text), translation.currentLocale).format(parameterValues.toTypedArray())
        }
 
        private fun getText(data: Any?) = (data as? L10nText)?.text ?: data.toString()