KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > l10n > GlobalL10nSettings


1 /* ************************************************************************** *
2  * Copyright (C) 2004 NightLabs GmbH, Marco Schulze *
3  * All rights reserved. *
4  * http://www.NightLabs.de *
5  * *
6  * This program and the accompanying materials are free software; you can re- *
7  * distribute it and/or modify it under the terms of the GNU General Public *
8  * License as published by the Free Software Foundation; either ver 2 of the *
9  * License, or any later version. *
10  * *
11  * This module is distributed in the hope that it will be useful, but WITHOUT *
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- *
13  * NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more *
14  * details. *
15  * *
16  * You should have received a copy of the GNU General Public License along *
17  * with this module; if not, write to the Free Software Foundation, Inc.: *
18  * 59 Temple Place, Suite 330 *
19  * Boston MA 02111-1307 *
20  * USA *
21  * *
22  * Or get it online: *
23  * http://www.opensource.org/licenses/gpl-license.php *
24  * *
25  * In case, you want to use this module or parts of it in a proprietary pro- *
26  * ject, you can purchase it under the NightLabs Commercial License. Please *
27  * contact NightLabs GmbH under info AT nightlabs DOT com for more infos or *
28  * visit http://www.NightLabs.com *
29  * ************************************************************************** */

30
31 /*
32  * Created on Dec 23, 2004
33  */

34 package com.nightlabs.l10n;
35
36 import java.util.Locale JavaDoc;
37
38 import com.nightlabs.config.ConfigModule;
39 import com.nightlabs.config.InitException;
40
41 /**
42  * @author Marco Schulze - marco at nightlabs dot de
43  */

44 public class GlobalL10nSettings extends ConfigModule
45 {
46     private boolean autoDetect = false;
47     private String JavaDoc language;
48     private String JavaDoc country;
49
50     public GlobalL10nSettings()
51     {
52     }
53
54     public void init() throws InitException
55     {
56         Locale JavaDoc locale = Locale.getDefault();
57
58         if (language == null || country == null)
59             setAutoDetect(true);
60
61         if (autoDetect == true) {
62             setLanguage(locale.getLanguage());
63             setCountry(locale.getCountry());
64         }
65         else {
66             System.setProperty("user.language", language);
67             System.setProperty("user.country", country);
68             Locale.setDefault(new Locale JavaDoc(language, country));
69         }
70     }
71     /**
72      * @return Returns the autoDetect.
73      */

74     public boolean isAutoDetect()
75     {
76         return autoDetect;
77     }
78     /**
79      * @param autoDetect The autoDetect to set.
80      */

81     public void setAutoDetect(boolean autoDetect)
82     {
83         this.autoDetect = autoDetect;
84         setChanged();
85     }
86     /**
87      * @return Returns the country.
88      */

89     public String JavaDoc getCountry()
90     {
91         return country;
92     }
93     /**
94      * @param country The country to set.
95      */

96     public void setCountry(String JavaDoc country)
97     {
98         this.country = country;
99         setChanged();
100     }
101     /**
102      * @return Returns the language.
103      */

104     public String JavaDoc getLanguage()
105     {
106         return language;
107     }
108     /**
109      * @param language The language to set.
110      */

111     public void setLanguage(String JavaDoc language)
112     {
113         this.language = language;
114         setChanged();
115     }
116 }
117
Popular Tags