From: David ‘Bombe’ Roden Date: Mon, 7 Apr 2008 09:17:23 +0000 (+0000) Subject: add possibility to replace stuff in labels X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a31631c92105e985c84e0b79656d35fe3a774f91;p=jSite2.git add possibility to replace stuff in labels git-svn-id: http://trooper/svn/projects/jSite/trunk@638 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java b/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java index c8bd089..f39b254 100644 --- a/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java +++ b/src/net/pterodactylus/jsite/i18n/gui/I18nLabel.java @@ -37,6 +37,9 @@ public class I18nLabel extends JLabel implements I18nable { /** The I18n basename of the label. */ private final String i18nBasename; + /** Optional arguments for i18n replacement. */ + private final Object[] arguments; + /** * Creates a new label with the given I18n basename. * @@ -44,7 +47,7 @@ public class I18nLabel extends JLabel implements I18nable { * The I18n basename of the label */ public I18nLabel(String i18nBasename) { - this(i18nBasename, null); + this(i18nBasename, (Component) null); } /** @@ -59,8 +62,41 @@ public class I18nLabel extends JLabel implements I18nable { * component */ public I18nLabel(String i18nBasename, Component component) { + this(i18nBasename, component, (Object[]) null); + } + + /** + * Creates a new label with the given I18n basename that optionally is a + * label for the given component. + * + * @param i18nBasename + * The I18n basename of the label + * @param arguments + * Optional arguments that are handed in to + * {@link I18n#get(String, Object...)} + */ + public I18nLabel(String i18nBasename, Object... arguments) { + this(i18nBasename, null, arguments); + } + + /** + * Creates a new label with the given I18n basename that optionally is a + * label for the given component. + * + * @param i18nBasename + * The I18n basename of the label + * @param component + * The component that is activated by the label, or + * null if this label should not activate a + * component + * @param arguments + * Optional arguments that are handed in to + * {@link I18n#get(String, Object...)} + */ + public I18nLabel(String i18nBasename, Component component, Object... arguments) { super(); this.i18nBasename = i18nBasename; + this.arguments = arguments; updateI18n(); if (component != null) { setLabelFor(component); @@ -71,7 +107,7 @@ public class I18nLabel extends JLabel implements I18nable { * {@inheritDoc} */ public void updateI18n() { - setText(I18n.get(i18nBasename + ".name")); + setText(I18n.get(i18nBasename + ".name", arguments)); setDisplayedMnemonic(I18n.getKey(i18nBasename + ".mnemonic")); }