2
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
/**
|
|
24 |
@test
|
|
25 |
@summary checking localised language/country names in finnish
|
|
26 |
@bug 4429024 4964035 6558856
|
|
27 |
*/
|
|
28 |
|
|
29 |
import java.util.Locale;
|
|
30 |
|
|
31 |
public class Bug4429024 {
|
|
32 |
|
|
33 |
public static void main(String[] args) throws Exception {
|
|
34 |
|
|
35 |
int errors=0;
|
|
36 |
|
|
37 |
String [][] fiLocales = {
|
|
38 |
{ "ar", "arabia" },
|
|
39 |
{ "ba", "baski" },
|
|
40 |
{ "bg", "bulgaria" },
|
|
41 |
{ "ca", "katalaani" },
|
|
42 |
{ "cs", "tsekki" },
|
|
43 |
{ "da", "tanska" },
|
|
44 |
{ "de", "saksa" },
|
|
45 |
{ "el", "kreikka" },
|
|
46 |
{ "en", "englanti" },
|
|
47 |
{ "es", "espanja" },
|
|
48 |
{ "fi", "suomi" },
|
|
49 |
{ "fr", "franska" },
|
|
50 |
{ "he", "heprea" },
|
|
51 |
{ "hi", "hindi" },
|
|
52 |
{ "it", "italia" },
|
|
53 |
{ "ja", "japani" },
|
|
54 |
{ "lt", "liettua" },
|
|
55 |
{ "lv", "latvia" },
|
|
56 |
{ "nl", "hollanti" },
|
|
57 |
{ "no", "norja" },
|
|
58 |
{ "pl", "puola" },
|
|
59 |
{ "pt", "portugali" },
|
|
60 |
{ "ru", "ven\u00e4j\u00e4" },
|
|
61 |
{ "sv", "ruotsi" },
|
|
62 |
{ "th", "thai" },
|
|
63 |
{ "tr", "turkki" },
|
|
64 |
{ "zh", "kiina" }
|
|
65 |
};
|
|
66 |
|
|
67 |
String[][] fiCountries = {
|
|
68 |
{ "BE", "Belgia" },
|
|
69 |
{ "BR", "Brasilia" },
|
|
70 |
{ "CA", "Kanada" },
|
|
71 |
{ "CH", "Sveitsi" },
|
|
72 |
{ "CN", "Kiina" },
|
|
73 |
{ "CZ", "Tsekin tasavalta" },
|
|
74 |
{ "DE", "Saksa" },
|
|
75 |
{ "DK", "Tanska" },
|
|
76 |
{ "ES", "Espanja" },
|
|
77 |
{ "FI", "Suomi" },
|
|
78 |
{ "FR", "Franska" },
|
|
79 |
{ "GB", "Iso-Britannia" },
|
|
80 |
{ "GR", "Kreikka" },
|
|
81 |
{ "IE", "Irlanti" },
|
|
82 |
{ "IT", "Italia" },
|
|
83 |
{ "JP", "Japani" },
|
|
84 |
{ "KR", "Korea" },
|
|
85 |
{ "NL", "Alankomaat" },
|
|
86 |
{ "NO", "Norja" },
|
|
87 |
{ "PL", "Puola" },
|
|
88 |
{ "PT", "Portugali" },
|
|
89 |
{ "RU", "Ven\u00e4j\u00e4" },
|
|
90 |
{ "SE", "Ruotsi" },
|
|
91 |
{ "TR", "Turkki" },
|
|
92 |
{ "US", "Yhdysvallat" }
|
|
93 |
};
|
|
94 |
|
|
95 |
for (int i=0; i < fiLocales.length; i++) {
|
|
96 |
errors += getLanguage(fiLocales[i][0], fiLocales[i][1]);
|
|
97 |
}
|
|
98 |
|
|
99 |
for (int i=0; i < fiCountries.length; i++) {
|
|
100 |
errors += getCountry(fiCountries[i][0], fiCountries[i][1]);
|
|
101 |
}
|
|
102 |
|
|
103 |
if(errors > 0){
|
|
104 |
throw new RuntimeException();
|
|
105 |
}
|
|
106 |
};
|
|
107 |
|
|
108 |
|
|
109 |
static int getLanguage(String inLang, String localizedName){
|
|
110 |
|
|
111 |
Locale fiLocale = new Locale("fi", "FI");
|
|
112 |
Locale inLocale = new Locale (inLang, "");
|
|
113 |
|
|
114 |
if (!inLocale.getDisplayLanguage(fiLocale).equals(localizedName)){
|
|
115 |
System.out.println("Language " + inLang +" should be \"" + localizedName + "\", not \"" + inLocale.getDisplayLanguage(fiLocale) + "\"");
|
|
116 |
return 1;
|
|
117 |
}
|
|
118 |
else{
|
|
119 |
return 0;
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
static int getCountry(String inCountry, String localizedName){
|
|
124 |
|
|
125 |
Locale fiLocale = new Locale("fi", "FI");
|
|
126 |
Locale inLocale = new Locale ("", inCountry);
|
|
127 |
|
|
128 |
if (!inLocale.getDisplayCountry(fiLocale).equals(localizedName)){
|
|
129 |
System.out.println("Country " + inCountry + " should be \"" + localizedName + "\", not \"" + inLocale.getDisplayCountry(fiLocale) + "\"");
|
|
130 |
return 1;
|
|
131 |
}
|
|
132 |
else{
|
|
133 |
return 0;
|
|
134 |
}
|
|
135 |
|
|
136 |
}
|
|
137 |
}
|