aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/viewer/Translator.java
blob: 0f9a5cc8ff92f696b89d18b86c2feee1259816ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * $Id$
 * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 * For details on use and redistribution please refer to the
 * LICENSE file included with these sources.
 */

package org.apache.fop.viewer;

//Java
import java.util.ResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;

/**
 * AWT Viewer's localization class, backed up by <code>java.util.ResourceBundle</code>.
 * Originally contributed by:
 * Stanislav.Gorkhover@jCatalog.com
 */
public class Translator {
    private ResourceBundle bundle;
    private static String bundleBaseName = "org/apache/fop/viewer/resources/Viewer";

    /**
     * Default constructor, default <code>Locale</code> is used.
     */
    public Translator() {
        this(Locale.getDefault());
    }

    /**
     * Constructor for a given <code>Locale</code>.
     */
    public Translator(Locale locale) {
        bundle = ResourceBundle.getBundle(bundleBaseName, locale);
    }

    /**
     * Returns localized <code>String</code> for a given key.
     */
    public String getString(String key) {
        return bundle.getString(key);
    }
}