import javax.swing.Icon;
import net.pterodactylus.jsite.i18n.I18n;
+import net.pterodactylus.jsite.i18n.I18nable;
/**
* Helper class that initializes actions with values from {@link I18n}.
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public abstract class I18nAction extends AbstractAction {
+public abstract class I18nAction extends AbstractAction implements I18nable {
+
+ /** The I18n basename. */
+ private final String i18nName;
/**
* Creates a new action that uses the given name as base name to get values
* The icon for the action
*/
public I18nAction(String i18nName, boolean enabled, Icon icon) {
- putValue(Action.NAME, I18n.get(i18nName + ".name"));
- putValue(Action.MNEMONIC_KEY, (int) I18n.get(i18nName + ".mnemonic").charAt(0));
- putValue(Action.ACCELERATOR_KEY, I18n.getKeyStroke(i18nName + ".accelerator"));
- putValue(Action.SHORT_DESCRIPTION, I18n.get(i18nName + ".shortDescription"));
- putValue(Action.LONG_DESCRIPTION, I18n.get(i18nName + ".longDescription"));
+ this.i18nName = i18nName;
if (icon != null) {
putValue(Action.SMALL_ICON, icon);
}
setEnabled(enabled);
+ updateI18n();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateI18n() {
+ putValue(Action.NAME, I18n.get(i18nName + ".name"));
+ putValue(Action.MNEMONIC_KEY, I18n.getKey(i18nName + ".mnemonic"));
+ putValue(Action.ACCELERATOR_KEY, I18n.getKeyStroke(i18nName + ".accelerator"));
+ putValue(Action.SHORT_DESCRIPTION, I18n.get(i18nName + ".shortDescription"));
+ putValue(Action.LONG_DESCRIPTION, I18n.get(i18nName + ".longDescription"));
}
}
\ No newline at end of file