Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.i18n / src / main / java / org / gvsig / i18n / tools / impl / DefaultI18Manager.java @ 44338

History | View | Annotate | Download (2.44 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.i18n.tools.impl;
25

    
26
import java.io.File;
27
import java.net.MalformedURLException;
28
import java.util.List;
29
import java.util.Locale;
30

    
31
import org.gvsig.i18n.Messages;
32
import org.gvsig.tools.i18n.I18nManager;
33

    
34
/**
35
 * This manager is in charge of providing with a richer text translation than
36
 * the one used by default.
37
 *
38
 *
39
 * @author gvSIG Team
40
 *
41
 */
42
public class DefaultI18Manager implements I18nManager {
43

    
44
    @Override
45
    public String getTranslation(String message) {
46
        return Messages.getText(message);
47
    }
48

    
49
    @Override
50
    public String getTranslation(String message, String[] args) {
51
        return Messages.getText(message, args);
52
    }
53

    
54
    @Override
55
    public void addResourceFamily(String family, ClassLoader loader,
56
            String callerName) {
57
        if (!Messages.hasLocales()) {
58
            Messages.addLocale(Locale.getDefault());
59
        }
60
        Messages.addResourceFamily(family, loader, callerName);
61
    }
62

    
63
    @Override
64
    public void addResourceFamily(String family, File folder) {
65
        if (!Messages.hasLocales()) {
66
            Messages.addLocale(Locale.getDefault());
67
        }
68
        try {
69
            Messages.addResourceFamily(family, folder);
70
        } catch (MalformedURLException ex) {
71
            throw new RuntimeException(ex);
72
        }
73
    }
74

    
75
    @Override
76
    public List<Locale> getPreferredLocales() {
77
        return Messages.getPreferredLocales();
78
    }
79

    
80
    @Override
81
    public Locale getCurrentLocale() {
82
        return Messages.getCurrentLocale();
83
    }
84
}