| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #include "subtitlelanguage.h" |
| 16 | |
| 17 | SubtitleLanguage::SubtitleLanguage(QString source) { |
| 18 | fill_tables(); |
| 19 | |
| 20 | setLanguage(source); |
| 21 | } |
| 22 | |
| 23 | void SubtitleLanguage::setLanguage(QString source) { |
| 24 | idx = -1; |
| 25 | |
| 26 | if (source.length() == 2) { |
| 27 | idx = codes2l.indexOf(source.toLower()); |
| 28 | } else if (source.length() == 3) { |
| 29 | idx = codes3l.indexOf(source.toLower()); |
| 30 | } else { |
| 31 | idx = names.indexOf(source); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | QString SubtitleLanguage::toTwoLetter() { |
| 36 | if (idx > -1) { |
| 37 | return codes2l.at(idx); |
| 38 | } |
| 39 | return ""; |
| 40 | } |
| 41 | |
| 42 | QString SubtitleLanguage::toTriLetter() { |
| 43 | if (idx > -1) { |
| 44 | return codes3l.at(idx); |
| 45 | } |
| 46 | return ""; |
| 47 | } |
| 48 | |
| 49 | QString SubtitleLanguage::toFullName() { |
| 50 | if (idx > -1) { |
| 51 | return names.at(idx); |
| 52 | } |
| 53 | return ""; |
| 54 | } |
| 55 | |
| 56 | QStringList SubtitleLanguage::listLanguages() { return names; } |
| 57 | |
| 58 | QStringList SubtitleLanguage::listLanguageTwoLetterCodes() { return codes2l; } |
| 59 | |
| 60 | void SubtitleLanguage::fill_tables() { |
| 61 | codes2l << "sq"; |
| 62 | codes3l << "alb"; |
| 63 | names << QObject::tr("Albanian"); |
| 64 | |
| 65 | codes2l << "en"; |
| 66 | codes3l << "eng"; |
| 67 | names << QObject::tr("English"); |
| 68 | |
| 69 | codes2l << "ar"; |
| 70 | codes3l << "ara"; |
| 71 | names << QObject::tr("Arabic"); |
| 72 | |
| 73 | codes2l << "bg"; |
| 74 | codes3l << "bul"; |
| 75 | names << QObject::tr("Bulgarian"); |
| 76 | |
| 77 | codes2l << "zh"; |
| 78 | codes3l << "chi"; |
| 79 | names << QObject::tr("Chinese"); |
| 80 | |
| 81 | codes2l << "hr"; |
| 82 | codes3l << "hrv"; |
| 83 | names << QObject::tr("Croatian"); |
| 84 | |
| 85 | codes2l << "cs"; |
| 86 | codes3l << "cze"; |
| 87 | names << QObject::tr("Czech"); |
| 88 | |
| 89 | codes2l << "da"; |
| 90 | codes3l << "dan"; |
| 91 | names << QObject::tr("Danish"); |
| 92 | |
| 93 | codes2l << "et"; |
| 94 | codes3l << "est"; |
| 95 | names << QObject::tr("Estonian"); |
| 96 | |
| 97 | codes2l << "fi"; |
| 98 | codes3l << "fin"; |
| 99 | names << QObject::tr("Finnish"); |
| 100 | |
| 101 | codes2l << "fr"; |
| 102 | codes3l << "fre"; |
| 103 | names << QObject::tr("French"); |
| 104 | |
| 105 | codes2l << "gl"; |
| 106 | codes3l << "glg"; |
| 107 | names << QObject::tr("Galician"); |
| 108 | |
| 109 | codes2l << "el"; |
| 110 | codes3l << "ell"; |
| 111 | names << QObject::tr("Greek"); |
| 112 | |
| 113 | codes2l << "he"; |
| 114 | codes3l << "heb"; |
| 115 | names << QObject::tr("Hebrew"); |
| 116 | |
| 117 | codes2l << "es"; |
| 118 | codes3l << "spa"; |
| 119 | names << QObject::tr("Spanish"); |
| 120 | |
| 121 | codes2l << "nl"; |
| 122 | codes3l << "dut"; |
| 123 | names << QObject::tr("Dutch"); |
| 124 | |
| 125 | codes2l << "id"; |
| 126 | codes3l << "ind"; |
| 127 | names << QObject::tr("Indonesian"); |
| 128 | |
| 129 | codes2l << "ja"; |
| 130 | codes3l << "jpn"; |
| 131 | names << QObject::tr("Japanese"); |
| 132 | |
| 133 | codes2l << "ko"; |
| 134 | codes3l << "kor"; |
| 135 | names << QObject::tr("Korean"); |
| 136 | |
| 137 | codes2l << "mk"; |
| 138 | codes3l << "mac"; |
| 139 | names << QObject::tr("Macedonian"); |
| 140 | |
| 141 | codes2l << "de"; |
| 142 | codes3l << "ger"; |
| 143 | names << QObject::tr("German"); |
| 144 | |
| 145 | codes2l << "no"; |
| 146 | codes3l << "nor"; |
| 147 | names << QObject::tr("Norwegian"); |
| 148 | |
| 149 | codes2l << "oc"; |
| 150 | codes3l << "oci"; |
| 151 | names << QObject::tr("Occitan"); |
| 152 | |
| 153 | codes2l << "fa"; |
| 154 | codes3l << "per"; |
| 155 | names << QObject::tr("Persian (farsi)"); |
| 156 | |
| 157 | codes2l << "pl"; |
| 158 | codes3l << "pol"; |
| 159 | names << QObject::tr("Polish"); |
| 160 | |
| 161 | codes2l << "pt"; |
| 162 | codes3l << "por"; |
| 163 | names << QObject::tr("Portuguese"); |
| 164 | |
| 165 | codes2l << "pb"; |
| 166 | codes3l << "pob"; |
| 167 | names << QObject::tr("Portuguese-BR"); |
| 168 | |
| 169 | codes2l << "ru"; |
| 170 | codes3l << "rus"; |
| 171 | names << QObject::tr("Russian"); |
| 172 | |
| 173 | codes2l << "ro"; |
| 174 | codes3l << "rum"; |
| 175 | names << QObject::tr("Romanian"); |
| 176 | |
| 177 | codes2l << "sr"; |
| 178 | codes3l << "scc"; |
| 179 | names << QObject::tr("Serbian"); |
| 180 | |
| 181 | codes2l << "sl"; |
| 182 | codes3l << "slv"; |
| 183 | names << QObject::tr("Slovenian"); |
| 184 | |
| 185 | codes2l << "sv"; |
| 186 | codes3l << "swe"; |
| 187 | names << QObject::tr("Swedish"); |
| 188 | |
| 189 | codes2l << "sk"; |
| 190 | codes3l << "slo"; |
| 191 | names << QObject::tr("Slovak"); |
| 192 | |
| 193 | codes2l << "tr"; |
| 194 | codes3l << "tur"; |
| 195 | names << QObject::tr("Turkish"); |
| 196 | |
| 197 | codes2l << "vi"; |
| 198 | codes3l << "vie"; |
| 199 | names << QObject::tr("Vietnamese"); |
| 200 | |
| 201 | codes2l << "hu"; |
| 202 | codes3l << "hun"; |
| 203 | names << QObject::tr("Hungarian"); |
| 204 | |
| 205 | codes2l << "it"; |
| 206 | codes3l << "ita"; |
| 207 | names << QObject::tr("Italian"); |
| 208 | } |