1 /* $RCSfile$ 2 * $Author$ 3 * $Date$ 4 * $Revision$ 5 * 6 * Copyright (C) 2011 The Jmol Development Team 7 * 8 * Contact: jmol-developers@lists.sf.net 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 23 * 02110-1301, USA. 24 */ 25 26 package org.jmol.i18n; 27 28 public class Language { 29 30 /** 31 * This is the place to put the list of supported languages. It is accessed 32 * by JmolPopup to create the menu list. Note that the names are in GT._ 33 * even though we set doTranslate false. That ensures that the language name 34 * IN THIS LIST is untranslated, but it provides the code xgettext needs in 35 * order to provide the list of names that will need translation by translators 36 * (the .po files). Later, in JmolPopup.updateLanguageMenu(), GT.$() is used 37 * again to create the actual, localized menu item name. 38 * 39 * list order: 40 * 41 * The order presented here is the order in which the list will be presented in the 42 * popup menu. In addition, the order of variants is significant. In all cases, place 43 * common-language entries in the following order: 44 * 45 * la_co_va 46 * la_co 47 * la 48 * 49 * In addition, there really is no need for "la" by itself. Every translator introduces 50 * a bias from their originating country. It would be perfectly fine if we had NO "la" 51 * items, and just la_co. Thus, we could have just: 52 * 53 * pt_BR 54 * pt_PT 55 * 56 * In this case, the "default" language translation should be entered LAST. 57 * 58 * If a user selects pt_ZQ, the code below will find (a) that we don't support pt_ZQ, 59 * (b) that we don't support pt_ZQ_anything, (c) that we don't support pt, and, finally, 60 * that we do support pt_PT, and it will select that one, returning to the user the message 61 * that language = "pt_PT" instead of pt_ZQ. 62 * 63 * For that matter, we don't even need anything more than 64 * 65 * la_co_va 66 * 67 * because the algorithm will track that down from anything starting with la, and in all cases 68 * find the closest match. 69 * 70 * Introduced in Jmol 11.1.34 71 * Author Bob Hanson May 7, 2007 72 * @return list of codes and untranslated names 73 */ 74 getLanguageList()75 public static Language[] getLanguageList() { 76 return new Language[] { 77 new Language("ar", GT.$("Arabic"), "العربية", false), 78 new Language("ast", GT.$("Asturian"), "Asturian", false), 79 new Language("az", GT.$("Azerbaijani"), "azərbaycan dili", false), 80 new Language("bs", GT.$("Bosnian"), "bosanski jezik", false), 81 new Language("ca", GT.$("Catalan"), "Català", true), 82 new Language("cs", GT.$("Czech"), "Čeština", true), 83 new Language("da", GT.$("Danish"), "Dansk", true), 84 new Language("de", GT.$("German"), "Deutsch", true), 85 new Language("el", GT.$("Greek"), "Ελληνικά", false), 86 new Language("en_AU", GT.$("Australian English"), "Australian English", false), 87 new Language("en_GB", GT.$("British English"), "British English", true), 88 new Language("en_US", GT.$("American English"), "American English", true), // global default for "en" will be "en_US" 89 new Language("es", GT.$("Spanish"), "Español", true), 90 new Language("et", GT.$("Estonian"), "Eesti", false), 91 new Language("eu", GT.$("Basque"), "Euskara", true), 92 new Language("fi", GT.$("Finnish"), "Suomi", true), 93 new Language("fo", GT.$("Faroese"), "Føroyskt", false), 94 new Language("fr", GT.$("French"), "Français", true), 95 new Language("fy", GT.$("Frisian"), "Frysk", false), 96 new Language("gl", GT.$("Galician"), "Galego", false), 97 new Language("hr", GT.$("Croatian"), "Hrvatski", false), 98 new Language("hu", GT.$("Hungarian"), "Magyar", true), 99 new Language("hy", GT.$("Armenian"), "Հայերեն", false), 100 new Language("id", GT.$("Indonesian"), "Indonesia", true), 101 new Language("it", GT.$("Italian"), "Italiano", true), 102 new Language("ja", GT.$("Japanese"), "日本語", true), 103 new Language("jv", GT.$("Javanese"), "Basa Jawa", false), 104 new Language("ko", GT.$("Korean"), "한국어", true), 105 new Language("ms", GT.$("Malay"), "Bahasa Melayu", true), 106 new Language("nb", GT.$("Norwegian Bokmal"), "Norsk Bokmål", false), 107 new Language("nl", GT.$("Dutch"), "Nederlands", true), 108 new Language("oc", GT.$("Occitan"), "Occitan", false), 109 new Language("pl", GT.$("Polish"), "Polski", false), 110 new Language("pt", GT.$("Portuguese"), "Português", false), 111 new Language("pt_BR", GT.$("Brazilian Portuguese"), "Português brasileiro", true), 112 new Language("ru", GT.$("Russian"), "Русский", true), 113 new Language("sl", GT.$("Slovenian"), "Slovenščina", false), 114 new Language("sr", GT.$("Serbian"), "српски језик", false), 115 new Language("sv", GT.$("Swedish"), "Svenska", true), 116 new Language("ta", GT.$("Tamil"), "தமிழ்", false), 117 new Language("te", GT.$("Telugu"), "తెలుగు", false), 118 new Language("tr", GT.$("Turkish"), "Türkçe", true), 119 new Language("ug", GT.$("Uyghur"), "Uyƣurqə", false), 120 new Language("uk", GT.$("Ukrainian"), "Українська", true), 121 new Language("uz", GT.$("Uzbek"), "O'zbek", false), 122 new Language("zh_CN", GT.$("Simplified Chinese"), "简体中文", true), 123 new Language("zh_TW", GT.$("Traditional Chinese"), "繁體中文", true), 124 }; 125 } 126 127 public final String code; 128 public final String language; 129 public final String nativeLanguage; 130 public boolean display; 131 132 /** 133 * @param code Language code (see ISO 639-1 for the values) 134 * @param language Language name in English (see ISO 639-1 for the values) 135 * @param nativeLanguage Language name in its own language (see ISO 639-1 for the values) 136 * @param display True if this language has a good percentage of translations done 137 * 138 * {@link "http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes"} 139 */ Language(String code, String language, String nativeLanguage, boolean display)140 private Language(String code, String language, String nativeLanguage, boolean display) { 141 this.code = code; 142 this.language = language; 143 this.nativeLanguage = nativeLanguage; 144 this.display = display; 145 } 146 getSupported(Language[] list, String code)147 static String getSupported(Language[] list, String code) { 148 for (int i = list.length; --i >= 0;) 149 if (list[i].code.equalsIgnoreCase(code)) 150 return list[i].code; 151 for (int i = list.length; --i >= 0;) 152 if (list[i].code.startsWith(code)) 153 return list[i].code; 154 return null; 155 } 156 157 }