1 /* 2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 /* 24 * @test 25 * @summary checking localised language/country names in finnish 26 * @modules jdk.localedata 27 * @bug 4429024 4964035 6558856 8008577 28 * @run main/othervm -Djava.locale.providers=JRE,SPI Bug4429024 29 */ 30 31 import java.util.Locale; 32 33 public class Bug4429024 { 34 35 public static void main(String[] args) throws Exception { 36 37 int errors=0; 38 39 String [][] fiLocales = { 40 { "ar", "arabia" }, 41 { "ba", "baski" }, 42 { "bg", "bulgaria" }, 43 { "ca", "katalaani" }, 44 { "cs", "tsekki" }, 45 { "da", "tanska" }, 46 { "de", "saksa" }, 47 { "el", "kreikka" }, 48 { "en", "englanti" }, 49 { "es", "espanja" }, 50 { "fi", "suomi" }, 51 { "fr", "ranska" }, 52 { "he", "heprea" }, 53 { "hi", "hindi" }, 54 { "it", "italia" }, 55 { "ja", "japani" }, 56 { "lt", "liettua" }, 57 { "lv", "latvia" }, 58 { "nl", "hollanti" }, 59 { "no", "norja" }, 60 { "pl", "puola" }, 61 { "pt", "portugali" }, 62 { "ru", "ven\u00e4j\u00e4" }, 63 { "sv", "ruotsi" }, 64 { "th", "thai" }, 65 { "tr", "turkki" }, 66 { "zh", "kiina" } 67 }; 68 69 String[][] fiCountries = { 70 { "BE", "Belgia" }, 71 { "BR", "Brasilia" }, 72 { "CA", "Kanada" }, 73 { "CH", "Sveitsi" }, 74 { "CN", "Kiina" }, 75 { "CZ", "Tsekin tasavalta" }, 76 { "DE", "Saksa" }, 77 { "DK", "Tanska" }, 78 { "ES", "Espanja" }, 79 { "FI", "Suomi" }, 80 { "FR", "Ranska" }, 81 { "GB", "Iso-Britannia" }, 82 { "GR", "Kreikka" }, 83 { "IE", "Irlanti" }, 84 { "IT", "Italia" }, 85 { "JP", "Japani" }, 86 { "KR", "Korea" }, 87 { "NL", "Alankomaat" }, 88 { "NO", "Norja" }, 89 { "PL", "Puola" }, 90 { "PT", "Portugali" }, 91 { "RU", "Ven\u00e4j\u00e4" }, 92 { "SE", "Ruotsi" }, 93 { "TR", "Turkki" }, 94 { "US", "Yhdysvallat" } 95 }; 96 97 for (int i=0; i < fiLocales.length; i++) { 98 errors += getLanguage(fiLocales[i][0], fiLocales[i][1]); 99 } 100 101 for (int i=0; i < fiCountries.length; i++) { 102 errors += getCountry(fiCountries[i][0], fiCountries[i][1]); 103 } 104 105 if(errors > 0){ 106 throw new RuntimeException(); 107 } 108 }; 109 110 111 static int getLanguage(String inLang, String localizedName){ 112 113 Locale fiLocale = new Locale("fi", "FI"); 114 Locale inLocale = new Locale (inLang, ""); 115 116 if (!inLocale.getDisplayLanguage(fiLocale).equals(localizedName)){ 117 System.out.println("Language " + inLang +" should be \"" + localizedName + "\", not \"" + inLocale.getDisplayLanguage(fiLocale) + "\""); 118 return 1; 119 } 120 else{ 121 return 0; 122 } 123 } 124 125 static int getCountry(String inCountry, String localizedName){ 126 127 Locale fiLocale = new Locale("fi", "FI"); 128 Locale inLocale = new Locale ("", inCountry); 129 130 if (!inLocale.getDisplayCountry(fiLocale).equals(localizedName)){ 131 System.out.println("Country " + inCountry + " should be \"" + localizedName + "\", not \"" + inLocale.getDisplayCountry(fiLocale) + "\""); 132 return 1; 133 } 134 else{ 135 return 0; 136 } 137 138 } 139 }