/[schmitzm]/branches/2.4.x/src/skrueger/i8n/PropertiesLocale.java
ViewVC logotype

Annotation of /branches/2.4.x/src/skrueger/i8n/PropertiesLocale.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1373 - (hide annotations)
Wed Jan 19 12:59:51 2011 UTC (14 years, 1 month ago) by alfonx
Original Path: trunk/src/skrueger/i8n/PropertiesLocale.java
File MIME type: text/plain
File size: 1447 byte(s)
GP-Feature: Added support for "user defined Locales". This allows to define a language, that is only spoken in a small area and which is not a official ISO language.
1 alfonx 1373 package skrueger.i8n;
2    
3     import java.util.HashMap;
4     import java.util.Locale;
5    
6     /**
7     */
8     public class PropertiesLocale {
9    
10     /**
11     * Language names => Translations
12     */
13     HashMap<String, String> displayLanguages = new HashMap<String, String>();
14    
15     private final Locale locale;
16    
17     private final String nativeName;
18    
19     private final Locale parentLocale;
20    
21     public PropertiesLocale(Locale locale, Locale parentLocale,
22     String nativeName) {
23     if (I8NUtil.isValidISOLangCode(locale.getLanguage()))
24     throw new IllegalArgumentException(
25     locale.getLanguage()
26     + " can not be defined as a PropertiesLocale langauge, since it is an existing ISO language code.");
27    
28     this.parentLocale = parentLocale;
29     this.locale = locale;
30     this.nativeName = nativeName;
31     }
32    
33     public String getDisplayLanguage(String langCode) {
34     if (langCode == null || displayLanguages.containsKey(langCode))
35     return displayLanguages.get(langCode);
36     else
37     return nativeName;
38     }
39    
40     public String getDisplayLanguage() {
41     return getDisplayLanguage(Locale.getDefault().getLanguage());
42     }
43    
44     public void setDisplayLanguages(String langCode, String languageName) {
45     displayLanguages.put(langCode, languageName);
46     }
47    
48     public String getLanguage() {
49     return locale.getLanguage();
50     }
51    
52     public String getCountry() {
53     return locale.getCountry();
54     }
55    
56     public String getDisplayCountry() {
57     return locale.getDisplayCountry();
58     }
59    
60     public Locale getParentLocale() {
61     return parentLocale;
62     }
63     }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26