1 package net.sourceforge.phpeclipse.wiki.actions.mediawiki.config;
2 //Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
3 //http://www.djini.de/software/wikipedia/index.html
5 //The modified sources are available under the "Common Public License"
6 //with permission from the original author: Daniel Wunsch
8 import java.io.IOException;
9 import java.io.InputStream;
10 import java.text.MessageFormat;
11 import java.util.MissingResourceException;
12 import java.util.PropertyResourceBundle;
13 import java.util.ResourceBundle;
15 import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
17 import org.eclipse.core.runtime.Path;
19 public class WikiProperties {
21 private static final String PACKAGE_NAME = WikiProperties.class.getPackage().getName();
23 private String RESOURCE_BUNDLE = null;
25 private ResourceBundle fgResourceBundle = null;
27 protected WikiProperties(String locale) {
29 InputStream is = WikiEditorPlugin.getDefault().openStream(new Path("wikis/"+locale+".properties"));
30 fgResourceBundle = new PropertyResourceBundle(is);
31 // RESOURCE_BUNDLE = PACKAGE_NAME + "." + locale;
32 // fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
33 } catch (IOException e) {
34 // TODO Auto-generated catch block
40 public String getString(String key) {
42 return fgResourceBundle.getString(key);
43 } catch (MissingResourceException e) {
44 return '!' + key + '!';
49 * Gets a string from the resource bundle and formats it with the argument
52 * the string used to get the bundle value, must not be null
54 public String getFormattedString(String key, Object arg) {
55 return MessageFormat.format(getString(key), new Object[] { arg });
59 * Gets a string from the resource bundle and formats it with arguments
61 public String getFormattedString(String key, Object[] args) {
62 return MessageFormat.format(getString(key), args);
66 // public static void main(String[] args) {
67 // WikiProperties p = new WikiProperties("EN");
68 // System.out.println(p.getString("uploadNoLogin"));