Bug4175998Test.java revision 0
2362N/A * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2362N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A @summary test ISO639-2 language codes 0N/A @run main Bug4175998Test 0N/A * (C) Copyright IBM Corp. 1998 - All Rights Reserved 0N/A * Portions Copyright 2007 by Sun Microsystems, Inc., 0N/A * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. 0N/A * All rights reserved. 0N/A * This software is the confidential and proprietary information 0N/A * of Sun Microsystems, Inc. ("Confidential Information"). You 0N/A * shall not disclose such Confidential Information and shall use 0N/A * it only in accordance with the terms of the license agreement 0N/A * you entered into with Sun. 0N/A * The original version of this source code and documentation is 0N/A * copyrighted and owned by IBM. These materials are provided 0N/A * under terms of a License Agreement between IBM and Sun. 0N/A * This technology is protected by multiple US and International 0N/A * patents. This notice and attribution to IBM may not be removed. 0N/A * Bug4175998Test verifies that the following bug has been fixed: * Bug 4175998 - The java.util.Locale.getISO3Language() returns wrong result for a locale with * language code 'ta'(Tamil). //generateTables(); //uncomment this to regenerate data tables logln(
"Locale("+l+
") returned bad ISO3 language code." +
" Got '"+
iso3+
"' instead of '"+
localeCodes[
1]+
"'"/*+" or '"+localeCodes[2]+"'"*/);
errln(
"Bad ISO3 language codes detected.");
The following code was used to generate the table above from the two ISO standards. It matches the language names (not the codes) from both standards to associate the two and three letter codes. private static final String ISO639 = "d:\\temp\\iso639.txt"; private static void generateTables() { BufferedReader ISO639File = new BufferedReader(new FileReader(ISO639)); Hashtable i639 = new Hashtable(); for (String line = ISO639File.readLine(); line != null; line = ISO639File.readLine()) { if (!line.startsWith("#")) { final int ndx = line.indexOf(' '); final String arg1 = line.substring(0, ndx); final int ndx2 = line.indexOf(' ', ndx+1); final String arg2 = line.substring(ndx+1, ndx2 < 0 ? line.length() : ndx2); BufferedReader ISO6392File = new BufferedReader(new FileReader(ISO6392)); Hashtable i6392 = new Hashtable(); for (String line = ISO6392File.readLine(); line != null; line = ISO6392File.readLine()) { final int ndx = line.indexOf(' '); final int ndx2 = line.indexOf(' ', ndx+1); int ndx3 = line.indexOf(' ', ndx2+1); if (ndx3 < 0) ndx3 = line.length(); final String arg1 = line.substring(0, ndx); final String arg2 = line.substring(ndx+1, ndx2); final String arg3 = line.substring(ndx2+1, ndx3); i6392.put(arg3, new ISO6392Entry(arg1, arg2)); Enumeration keys = i639.keys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); final Object name = i639.get(key); final Object value = i6392.get(name); System.out.print("\""+key+"\","); System.out.println("},"); private static final class ISO6392Entry { public final String code; public final String name; public ISO6392Entry(String code, String name) { public String toString() { return "\""+code+"\",\""+name+"\""; afa afa Afro-Asiatic (Other) alg alg Algonquian languages ang ang English-Old (ca. 450-1100) art art Artificial (Other) ath ath Athapascan languages aus aus Australian languages bai bai Bamileke languages btk btk Batak (Indonesia) cai cai Central-American-Indian (Other) cau cau Caucasian (Other) cpe cpe Creoles-and-pidgins-English-based (Other) cpf cpf Creoles-and-pidgins-French-based (Other) cpp cpp Creoles-and-pidgins-Portuguese-based (Other) crp crp Creoles-and-pidgins (Other) den den Slave (Athapascan) dra dra Dravidian (Other) dum dum Dutch-Middle (ca. 1050-1350) egy egy Egyptian (Ancient) ell gre Greek Modern (post 1453) enm enm English-Middle (1100-1500) fiu fiu Finno-Ugrian (Other) frm frm French-Middle (ca. 1400-1600) fro fro French-Old (842-ca. 1400) gmh gmh German-Middle High (ca. 1050-1500) goh goh German-Old High (ca. 750-1050) grc grc Greek-Ancient (to 1453) ina ina Interlingua (International Auxilary Language Association) ine ine Indo-European (Other) iro iro Iroquoian languages luo luo Luo (Kenya and Tanzania) map map Austronesian (Other) mga mga Irish-Middle (900-1200) mis mis Miscellaneous languages mkh mkh Mon-Khmer (Other) mul mul Multiple languages nai nai North American Indian (Other) nic nic Niger-Kordofanian (Other) oci oci Occitan (post 1500) ota ota Turkish, Ottoman (1500-1928) oto oto Otomian languages peo peo Persian, Old (ca. 600-400 B.C.) phi phi Philippine (Other) pra pra Prakrit languages pro pro Proven�al, Old (to 1500) qaa-qtz qaa-qtz Reserved for local use sai sai South American Indian (Other) sal sal Salishan languages sam sam Samaritan Aramaic sga sga Irish-Old (to 900) sit sit Sino-Tibetan (Other) ssa ssa Nilo-Saharan (Other) ton ton Tonga (Tonga Islands)