1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / actions / mediawiki / config / WikiProperties.java
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
4 //
5 //The modified sources are available under the "Common Public License"
6 //with permission from the original author: Daniel Wunsch
7
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;
14
15 import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
16
17 import org.eclipse.core.runtime.Path;
18
19 public class WikiProperties {
20
21   private static final String PACKAGE_NAME = WikiProperties.class.getPackage().getName();
22
23   private String RESOURCE_BUNDLE = null;
24
25   private ResourceBundle fgResourceBundle = null;
26
27   protected WikiProperties(String locale) {
28     try {
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
35       e.printStackTrace();
36     }
37     
38   }
39
40   public String getString(String key) {
41     try {
42       return fgResourceBundle.getString(key);
43     } catch (MissingResourceException e) {
44       return '!' + key + '!';
45     }
46   }
47
48   /**
49    * Gets a string from the resource bundle and formats it with the argument
50    * 
51    * @param key
52    *          the string used to get the bundle value, must not be null
53    */
54   public String getFormattedString(String key, Object arg) {
55     return MessageFormat.format(getString(key), new Object[] { arg });
56   }
57
58   /**
59    * Gets a string from the resource bundle and formats it with arguments
60    */
61   public String getFormattedString(String key, Object[] args) {
62     return MessageFormat.format(getString(key), args);
63   }
64
65   // test code
66 //    public static void main(String[] args) {
67 //      WikiProperties p = new WikiProperties("EN");
68 //      System.out.println(p.getString("uploadNoLogin"));
69 //    }
70
71 }