X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetTranslationPage.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetTranslationPage.java;h=21ec083542b9c736ba25d1ed0b7bed0117c7b1f1;hb=976fe760eb678a414617aeea984ec89848b49d01;hp=0000000000000000000000000000000000000000;hpb=cb2f7e57a8ac1768da8f9c2a11d23118c1564f87;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java new file mode 100644 index 0000000..21ec083 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java @@ -0,0 +1,54 @@ +/* + * Sone - GetTranslationPage.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.web.ajax; + +import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.util.json.JsonObject; + +/** + * Returns the translation for a given key as JSON object. + * + * @author David ‘Bombe’ Roden + */ +public class GetTranslationPage extends JsonPage { + + /** The Sone web interface. */ + private WebInterface webInterface; + + /** + * Creates a new translation page. + * + * @param webInterface + * The Sone web interface + */ + public GetTranslationPage(WebInterface webInterface) { + super("ajax/getTranslation.ajax"); + this.webInterface = webInterface; + } + + /** + * {@inheritDoc} + */ + @Override + protected JsonObject createJsonObject(Request request) { + String key = request.getHttpRequest().getParam("key"); + String translation = webInterface.l10n().getString(key); + return new JsonObject().put("value", translation); + } + +}