]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_8_1_1/tools/misc/src/com/ibm/icu/dev/tool/layout/LanguageData.java
Added flags.
[Dictionary.git] / jars / icu4j-4_8_1_1 / tools / misc / src / com / ibm / icu / dev / tool / layout / LanguageData.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 1998-2008, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  *
7  * Created on Apr 4, 2003
8  *
9  *******************************************************************************
10  */
11 package com.ibm.icu.dev.tool.layout;
12
13 /**
14  * This class holds the list of languages.
15  * 
16  * @author emader
17  *
18  */
19 public class LanguageData extends TagValueData
20 {
21     public static class Record
22     {
23         private String tag;
24         private String name;
25         
26         public Record(String tag, String name)
27         {
28             this.tag = tag;
29             this.name = name;
30         }
31         
32         public String tag()
33         {
34             return tag;
35         }
36         
37         public String name()
38         {
39             return name;
40         }
41         
42         public String label()
43         {
44             return TagUtilities.tagLabel(tag);
45         }
46         
47         public String makeTag()
48         {
49             return TagUtilities.makeTag(tag);
50         }
51     }
52         
53     /*
54      * This is temporary data until there is some resolution between
55      * the OpenType language system tags and the ISO and RFC standards...
56      */
57     private Record[] languages =
58     {
59         new Record("",    "null"),
60         new Record("ARA", "Arabic"),
61         new Record("ASM", "Assamese"),
62         new Record("BEN", "Bengali"),
63         new Record("FAR", "Farsi"),
64         new Record("GUJ", "Gujarati"),
65         new Record("HIN", "Hindi"),
66         new Record("IWR", "Hebrew"),
67         new Record("JII", "Yiddish"),
68         new Record("JAN", "Japanese"),
69         new Record("KAN", "Kannada"),
70         new Record("KOK", "Konkani"),
71         new Record("KOR", "Korean"),
72         new Record("KSH", "Kashmiri"),
73         new Record("MAL", "Malayalam (Traditional)"),
74         new Record("MAR", "Marathi"),
75         new Record("MLR", "Malayalam (Reformed)"),
76         new Record("MNI", "Manipuri"),
77         new Record("ORI", "Oriya"),
78         new Record("SAN", "Sanscrit"),
79         new Record("SND", "Sindhi"),
80         new Record("SNH", "Sinhalese"),
81         new Record("SYR", "Syriac"),
82         new Record("TAM", "Tamil"),
83         new Record("TEL", "Telugu"),
84         new Record("THA", "Thai"),
85         new Record("URD", "Urdu"),
86         new Record("ZHP", "Chinese (Phonetic)"),
87         new Record("ZHS", "Chinese (Simplified)"),
88         new Record("ZHT", "Chinese (Traditional)"),
89         
90         // languages added on 03/13/2008
91         // TODO: need to deal with the fact that
92         // these codes should be @draft, and the above
93         // codes should be @final.
94         new Record("AFK", "Afrikaans"),
95         new Record("BEL", "Belarussian"),
96         new Record("BGR", "Bulgarian"),
97         new Record("CAT", "Catalan"),
98         new Record("CHE", "Chechen"),
99         new Record("COP", "Coptic"),
100         new Record("CSY", "Czech"),
101         new Record("DAN", "Danish"),
102         new Record("DEU", "German"),
103         new Record("DZN", "Dzongkha"),
104         new Record("ELL", "Greek"),
105         new Record("ENG", "English"),
106         new Record("ESP", "Spanish"),
107         new Record("ETI", "Estonian"),
108         new Record("EUQ", "Basque"),
109         new Record("FIN", "Finnish"),
110       //new Record("FLE", "Flemish"), // Flemish has the same ISO 639-2 code as Dutch (NLD)
111         new Record("FRA", "French"),
112         new Record("GAE", "Gaelic"),
113         new Record("HAU", "Hausa"),
114         new Record("HRV", "Croation"),
115         new Record("HUN", "Hungarian"),
116         new Record("HYE", "Armenian"),
117         new Record("IND", "Indonesian"),
118         new Record("ITA", "Italian"),
119         new Record("KHM", "Khmer"),
120         new Record("MNG", "Mongolian"),
121         new Record("MTS", "Maltese"),
122         new Record("NEP", "Nepali"),
123         new Record("NLD", "Dutch"),
124         new Record("PAS", "Pashto"),
125         new Record("PLK", "Polish"),
126         new Record("PTG", "Portuguese"),
127         new Record("ROM", "Romanian"),
128         new Record("RUS", "Russian"),
129         new Record("SKY", "Slovak"),
130         new Record("SLV", "Slovenian"),
131         new Record("SQI", "Albanian"),
132         new Record("SRB", "Serbian"),
133         new Record("SVE", "Swedish"),
134         new Record("TIB", "Tibetan"),
135         new Record("TRK", "Turkish"),
136         new Record("WEL", "Welsh")
137     };
138     
139     private int minLanguage = 0;
140     private int maxLanguage = minLanguage + languages.length - 1;
141     
142     public int getMinValue()
143     {
144         return minLanguage;
145     }
146     
147     public int getMaxValue()
148     {
149         return maxLanguage;
150     }
151     
152     public String getTag(int value)
153     {
154         if (value < minLanguage || value > maxLanguage) {
155             return null;
156         }
157         
158         return languages[value - minLanguage].tag();
159     }
160     
161     public String getTagLabel(int value)
162     {
163         if (value < minLanguage || value > maxLanguage) {
164             return null;
165         }
166         
167         return languages[value - minLanguage].label();
168     }
169     
170     public String makeTag(int value)
171     {
172         if (value < minLanguage || value > maxLanguage) {
173             return null;
174         }
175         
176         return languages[value - minLanguage].makeTag();
177     }
178     
179     public String getName(int value) {
180         if (value < minLanguage || value > maxLanguage) {
181             return "(UNKNOWN)";
182         }
183         
184         return languages[value - minLanguage].name();
185     }
186 }