/** * Create a new PluginL10n object using the node's selected * language. * @param plugin Plugin to use. */ public PluginL10n(FredPluginBaseL10n plugin) { this(plugin, NodeL10n.getBase().getSelectedLanguage()); }
@Override public String get() { return NodeL10n.getBase().getSelectedLanguage().fullName; }
@Override public String next() { if (state == FallbackState.CURRENT_LANG) { state = FallbackState.FALLBACK_LANG; String value = getString(key, true); if (value != null) { return value; } } if (state == FallbackState.FALLBACK_LANG) { state = FallbackState.KEY; if (getSelectedLanguage() != LANGUAGE.getDefault()) { String value = getFallbackString(key); if (value != null) { return value; } } } if (state == FallbackState.KEY) { state = FallbackState.END; return key; } throw new NoSuchElementException(); }
/** * {@inheritDoc} */ @Override public String format(TemplateContext templateContext, Object data, Map<String, Object> parameters) { List<Object> parameterValues = getParameters(data, parameters); String text = getText(data); if (parameterValues.isEmpty()) { return webInterface.getL10n().getString(text); } return new MessageFormat(webInterface.getL10n().getString(text), new Locale(webInterface.getL10n().getSelectedLanguage().shortCode)).format(parameterValues.toArray()); }
/** * Get a localized string. * @param key Key to search for. * @param returnNullIfNotFound If this is true, will return null if the key is not found. * @return String */ public String getString(String key, boolean returnNullIfNotFound) { if (!returnNullIfNotFound) { return getString(key); } String result = null; if (this.translationOverride != null) { result = this.translationOverride.get(key); } if (result != null) { return result; } if (this.currentTranslation != null) { result = this.currentTranslation.get(key); } if (result == null) { Logger.normal(this.getClass(), "The translation for " + key + " hasn't been found (" + this.getSelectedLanguage() + ")! please tell the maintainer."); } return result; }
@Override public void set(String val) throws InvalidConfigValueException { if(val == null || get().equalsIgnoreCase(val)) return; try { NodeL10n.getBase().setLanguage(BaseL10n.LANGUAGE.mapToLanguage(val)); } catch (MissingResourceException e) { throw new InvalidConfigValueException(e.getLocalizedMessage()); } PluginManager.setLanguage(NodeL10n.getBase().getSelectedLanguage()); }
((FredPluginL10n)object).setLanguage(NodeL10n.getBase().getSelectedLanguage()); ((FredPluginBaseL10n)object).setLanguage(NodeL10n.getBase().getSelectedLanguage());
@Override public SimpleFieldSet getFieldSet() { SimpleFieldSet sfs = new SimpleFieldSet(true); // FIXME sfs.putSingle("FCPVersion", "2.0"); sfs.putSingle("Node", "Fred"); sfs.putSingle("Version", Version.getVersionString()); sfs.put("Build", Version.buildNumber()); sfs.putSingle("Revision", Version.cvsRevision()); sfs.put("ExtBuild", NodeStarter.extBuildNumber); sfs.putSingle("ExtRevision", NodeStarter.extRevisionNumber); sfs.put("Testnet", Node.isTestnetEnabled()); sfs.putSingle("CompressionCodecs", Compressor.COMPRESSOR_TYPE.getHelloCompressorDescriptor()); sfs.putSingle("ConnectionIdentifier", id); sfs.putSingle("NodeLanguage", NodeL10n.getBase().getSelectedLanguage().toString()); return sfs; }
boolean fullAccess = ctx == null ? false : ctx.isAllowedFullAccess(); HTMLNode pageNode = new HTMLNode.HTMLDoctype("html", "-//W3C//DTD XHTML 1.1//EN"); HTMLNode htmlNode = pageNode.addChild("html", "xml:lang", NodeL10n.getBase().getSelectedLanguage().isoCode); HTMLNode headNode = htmlNode.addChild("head"); headNode.addChild("meta", new String[] { "http-equiv", "content" }, new String[] { "Content-Type", "text/html; charset=utf-8" }); statusBarDiv.addChild("div", "id", "statusbar-language").addChild("a", "href", "/config/node#l10n", NodeL10n.getBase().getSelectedLanguage().fullName);
head.put("Content-Disposition", "attachment; filename=\"" + this.base.getL10nOverrideFileName(this.base.getSelectedLanguage()) + '"'); ctx.sendReplyHeaders(200, "Found", head, "text/plain; charset=utf-8", data.length); ctx.writeData(data); translationHeaderNode.addChild("#", l10n("contributingToLabelWithLang", "lang", this.base.getSelectedLanguage().fullName)); translationHeaderNode.addChild("a", "href", TOADLET_URL+"?getOverrideTranlationFile").addChild("#", l10n("downloadTranslationsFile")); translationHeaderNode.addChild("#", " ");