~librecad-dev/librecad/librecad

« back to all changes in this revision

Viewing changes to librecad/src/lib/engine/rs_system.cpp

  • Committer: Scott Howard
  • Date: 2014-02-21 19:07:55 UTC
  • Revision ID: showard@debian.org-20140221190755-csjax9wb146hgdq4
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** This file is part of the LibreCAD project, a 2D CAD program
 
4
**
 
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
 
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
 
7
**
 
8
**
 
9
** This file may be distributed and/or modified under the terms of the
 
10
** GNU General Public License version 2 as published by the Free Software
 
11
** Foundation and appearing in the file gpl-2.0.txt included in the
 
12
** packaging of this file.
 
13
**
 
14
** This program is distributed in the hope that it will be useful,
 
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
** GNU General Public License for more details.
 
18
**
 
19
** You should have received a copy of the GNU General Public License
 
20
** along with this program; if not, write to the Free Software
 
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
22
**
 
23
** This copyright notice MUST APPEAR in all copies of the script!
 
24
**
 
25
**********************************************************************/
 
26
 
 
27
#include <iostream>
 
28
#include <QMap>
 
29
#include <qapplication.h>
 
30
#include <QTextCodec>
 
31
#include <QTranslator>
 
32
#include <QFileInfo>
 
33
#include "rs_settings.h"
 
34
#include "rs_system.h"
 
35
#include "rs.h"
 
36
 
 
37
#if QT_VERSION < 0x040400
 
38
#include "emu_qt44.h"
 
39
#endif
 
40
 
 
41
#if QT_VERSION >= 0x050000
 
42
#include <QStandardPaths>
 
43
#else
 
44
#include <QDesktopServices>
 
45
#endif
 
46
 
 
47
RS_System* RS_System::uniqueInstance = NULL;
 
48
 
 
49
 
 
50
/**
 
51
 * Initializes the system.
 
52
 *
 
53
 * @param appName Application name (e.g. "librecad II")
 
54
 * @param appVersion Application version (e.g. "1.2.3")
 
55
 * @param appDirName Application directory name used for
 
56
 *     subdirectories in /usr, /etc ~/.
 
57
 * @param appDir Absolute application directory (e.g. /opt/qcad)
 
58
 *                 defaults to current directory.
 
59
 */
 
60
void RS_System::init(const QString& appName, const QString& appVersion,
 
61
                     const QString& appDirName, const QString& appDir) {
 
62
    this->appName = appName;
 
63
    this->appVersion = appVersion;
 
64
    this->appDirName = appDirName;
 
65
    if (appDir=="") {
 
66
        this->appDir = QDir::currentPath();
 
67
    } else {
 
68
        this->appDir = appDir;
 
69
    }
 
70
 
 
71
    RS_DEBUG->print("RS_System::init: System %s initialized.", appName.toLatin1().data());
 
72
    RS_DEBUG->print("RS_System::init: App dir: %s", appDir.toLatin1().data());
 
73
    initialized = true;
 
74
 
 
75
    initAllLanguagesList();
 
76
    initLanguageList();
 
77
}
 
78
 
 
79
 
 
80
 
 
81
/**
 
82
 * Initializes the list of available translations.
 
83
 */
 
84
void RS_System::initLanguageList() {
 
85
    RS_DEBUG->print("RS_System::initLanguageList");
 
86
    QStringList lst = getFileList("qm", "qm");
 
87
 
 
88
    RS_SETTINGS->beginGroup("/Paths");
 
89
    lst += (RS_SETTINGS->readEntry("/Translations", "")).split(";", QString::SkipEmptyParts);
 
90
    RS_SETTINGS->endGroup();
 
91
 
 
92
    for (QStringList::Iterator it = lst.begin();
 
93
            it!=lst.end();
 
94
            ++it) {
 
95
 
 
96
        RS_DEBUG->print("RS_System::initLanguageList: qm file: %s",
 
97
                        (*it).toLatin1().data());
 
98
//        std::cout<<"RS_System::initLanguageList: qm file: "<<(*it).toLatin1().data()<<std::endl;
 
99
 
 
100
        int i0 = (*it).lastIndexOf(QString("librecad"),-1,Qt::CaseInsensitive);
 
101
        int i1 = (*it).indexOf('_',i0);
 
102
        int i2 = (*it).indexOf('.', i1);
 
103
        if( i1 == -1 || i2 == -1 ) continue;
 
104
        QString l = (*it).mid(i1+1, i2-i1-1);
 
105
//        std::cout<<"RS_System::initLanguageList: l: "<<qPrintable(l)<<std::endl;
 
106
 
 
107
        if ( !(languageList.contains(l)) ) {
 
108
            RS_DEBUG->print("RS_System::initLanguageList: append language: %s",
 
109
                            l.toLatin1().data());
 
110
            languageList.append(l);
 
111
        }
 
112
    }
 
113
    RS_DEBUG->print("RS_System::initLanguageList: OK");
 
114
}
 
115
 
 
116
void RS_System::addLocale(RS_Locale *locale) {
 
117
    allKnownLocales.push_back(QSharedPointer<RS_Locale>(locale));
 
118
}
 
119
 
 
120
#define LNG(canonical, direction, name) \
 
121
    locale=new RS_Locale(); \
 
122
    locale->setCanonical(canonical); \
 
123
    locale->setDirection(direction); \
 
124
    locale->setName(name); \
 
125
    addLocale(locale);
 
126
 
 
127
void RS_System::initAllLanguagesList() {
 
128
 
 
129
    // RVT uk_AU renamed to uk so that we don't have to change the pootle server
 
130
    //
 
131
    allKnownLocales.clear();
 
132
    RS_Locale *locale;
 
133
    LNG("ab"   ,RS2::locLeftToRight, "Abkhazian")
 
134
    LNG("aa"   ,RS2::locLeftToRight, "Afar")
 
135
    LNG("af_ZA",RS2::locLeftToRight, "Afrikaans")
 
136
    LNG("sq_AL",RS2::locLeftToRight, "Albanian")
 
137
    LNG("am"   ,RS2::locLeftToRight, "Amharic")
 
138
    LNG("ar"   ,RS2::locRightToLeft, "Arabic")
 
139
    LNG("ar_DZ",RS2::locRightToLeft, "Arabic (Algeria)")
 
140
    LNG("ar_BH",RS2::locRightToLeft, "Arabic (Bahrain)")
 
141
    LNG("ar_EG",RS2::locRightToLeft, "Arabic (Egypt)")
 
142
    LNG("ar_IQ",RS2::locRightToLeft, "Arabic (Iraq)")
 
143
    LNG("ar_JO",RS2::locRightToLeft, "Arabic (Jordan)")
 
144
    LNG("ar_KW",RS2::locRightToLeft, "Arabic (Kuwait)")
 
145
    LNG("ar_LB",RS2::locRightToLeft, "Arabic (Lebanon)")
 
146
    LNG("ar_LY",RS2::locRightToLeft, "Arabic (Libya)")
 
147
    LNG("ar_MA",RS2::locRightToLeft, "Arabic (Morocco)")
 
148
    LNG("ar_OM",RS2::locRightToLeft, "Arabic (Oman)")
 
149
    LNG("ar_QA",RS2::locRightToLeft, "Arabic (Qatar)")
 
150
    LNG("ar_SA",RS2::locRightToLeft, "Arabic (Saudi Arabia)")
 
151
    LNG("ar_SD",RS2::locRightToLeft, "Arabic (Sudan)")
 
152
    LNG("ar_SY",RS2::locRightToLeft, "Arabic (Syria)")
 
153
    LNG("ar_TN",RS2::locRightToLeft, "Arabic (Tunisia)")
 
154
    LNG("ar_AE",RS2::locRightToLeft, "Arabic (Uae)")
 
155
    LNG("ar_YE",RS2::locRightToLeft, "Arabic (Yemen)")
 
156
    LNG("hy"   ,RS2::locLeftToRight, "Armenian")
 
157
    LNG("as"   ,RS2::locLeftToRight, "Assamese")
 
158
    LNG("ay"   ,RS2::locLeftToRight, "Aymara")
 
159
    LNG("az"   ,RS2::locLeftToRight, "Azeri")
 
160
    LNG("az"   ,RS2::locLeftToRight, "Azeri (Cyrillic)")
 
161
    LNG("az"   ,RS2::locLeftToRight, "Azeri (Latin)")
 
162
    LNG("ba"   ,RS2::locLeftToRight, "Bashkir")
 
163
    LNG("eu_ES",RS2::locLeftToRight, "Basque")
 
164
    LNG("be_BY",RS2::locLeftToRight, "Belarusian")
 
165
    LNG("bn"   ,RS2::locLeftToRight, "Bengali")
 
166
    LNG("dz"   ,RS2::locLeftToRight, "Bhutani")
 
167
    LNG("bh"   ,RS2::locLeftToRight, "Bihari")
 
168
    LNG("bi"   ,RS2::locLeftToRight, "Bislama")
 
169
    LNG("br"   ,RS2::locLeftToRight, "Breton")
 
170
    LNG("bg_BG",RS2::locLeftToRight, "Bulgarian")
 
171
    LNG("my"   ,RS2::locLeftToRight, "Burmese")
 
172
    LNG("km"   ,RS2::locLeftToRight, "Cambodian")
 
173
    LNG("ca_ES",RS2::locLeftToRight, "Catalan")
 
174
    LNG("zh_TW",RS2::locLeftToRight, "Chinese")
 
175
    LNG("zh_CN",RS2::locLeftToRight, "Chinese (Simplified)")
 
176
    LNG("zh_TW",RS2::locLeftToRight, "Chinese (Traditional)")
 
177
    LNG("zh_HK",RS2::locLeftToRight, "Chinese (Hongkong)")
 
178
    LNG("zh_MO",RS2::locLeftToRight, "Chinese (Macau)")
 
179
    LNG("zh_SG",RS2::locLeftToRight, "Chinese (Singapore)")
 
180
    LNG("zh_TW",RS2::locLeftToRight, "Chinese (Taiwan)")
 
181
    LNG("co"   ,RS2::locLeftToRight, "Corsican")
 
182
    LNG("hr_HR",RS2::locLeftToRight, "Croatian")
 
183
    LNG("cs_CZ",RS2::locLeftToRight, "Czech")
 
184
    LNG("da_DK",RS2::locLeftToRight, "Danish")
 
185
    LNG("nl_NL",RS2::locLeftToRight, "Dutch")
 
186
    LNG("nl_BE",RS2::locLeftToRight, "Dutch (Belgian)")
 
187
    LNG("en_GB",RS2::locLeftToRight, "English")
 
188
    LNG("en_GB",RS2::locLeftToRight, "English (U.K.)")
 
189
    LNG("en_US",RS2::locLeftToRight, "English (U.S.)")
 
190
    LNG("en_AU",RS2::locLeftToRight, "English (Australia)")
 
191
    LNG("en_BZ",RS2::locLeftToRight, "English (Belize)")
 
192
    LNG("en_BW",RS2::locLeftToRight, "English (Botswana)")
 
193
    LNG("en_CA",RS2::locLeftToRight, "English (Canada)")
 
194
    LNG("en_CB",RS2::locLeftToRight, "English (Caribbean)")
 
195
    LNG("en_DK",RS2::locLeftToRight, "English (Denmark)")
 
196
    LNG("en_IE",RS2::locLeftToRight, "English (Eire)")
 
197
    LNG("en_JM",RS2::locLeftToRight, "English (Jamaica)")
 
198
    LNG("en_NZ",RS2::locLeftToRight, "English (New Zealand)")
 
199
    LNG("en_PH",RS2::locLeftToRight, "English (Philippines)")
 
200
    LNG("en_ZA",RS2::locLeftToRight, "English (South Africa)")
 
201
    LNG("en_TT",RS2::locLeftToRight, "English (Trinidad)")
 
202
    LNG("en_ZW",RS2::locLeftToRight, "English (Zimbabwe)")
 
203
    LNG("eo"   ,RS2::locLeftToRight, "Esperanto")
 
204
    LNG("et_EE",RS2::locLeftToRight, "Estonian")
 
205
    LNG("fo_FO",RS2::locLeftToRight, "Faeroese")
 
206
    LNG("fa_IR",RS2::locLeftToRight, "Farsi")
 
207
    LNG("fj"   ,RS2::locLeftToRight, "Fiji")
 
208
    LNG("fi_FI",RS2::locLeftToRight, "Finnish")
 
209
    LNG("fr_FR",RS2::locLeftToRight, "French")
 
210
    LNG("fr_BE",RS2::locLeftToRight, "French (Belgian)")
 
211
    LNG("fr_CA",RS2::locLeftToRight, "French (Canadian)")
 
212
    LNG("fr_LU",RS2::locLeftToRight, "French (Luxembourg)")
 
213
    LNG("fr_MC",RS2::locLeftToRight, "French (Monaco)")
 
214
    LNG("fr_CH",RS2::locLeftToRight, "French (Swiss)")
 
215
    LNG("fy"   ,RS2::locLeftToRight, "Frisian")
 
216
    LNG("gl_ES",RS2::locLeftToRight, "Galician")
 
217
    LNG("ka_GE",RS2::locLeftToRight, "Georgian")
 
218
    LNG("de_DE",RS2::locLeftToRight, "German")
 
219
    LNG("de_AT",RS2::locLeftToRight, "German (Austrian)")
 
220
    LNG("de_BE",RS2::locLeftToRight, "German (Belgium)")
 
221
    LNG("de_LI",RS2::locLeftToRight, "German (Liechtenstein)")
 
222
    LNG("de_LU",RS2::locLeftToRight, "German (Luxembourg)")
 
223
    LNG("de_CH",RS2::locLeftToRight, "German (Swiss)")
 
224
    LNG("el_GR",RS2::locLeftToRight, "Greek")
 
225
    LNG("kl_GL",RS2::locLeftToRight, "Greenlandic")
 
226
    LNG("gn"   ,RS2::locLeftToRight, "Guarani")
 
227
    LNG("gu"   ,RS2::locLeftToRight, "Gujarati")
 
228
    LNG("ha"   ,RS2::locLeftToRight, "Hausa")
 
229
    LNG("he_IL",RS2::locRightToLeft, "Hebrew")
 
230
    LNG("hi_IN",RS2::locLeftToRight, "Hindi")
 
231
    LNG("hu_HU",RS2::locLeftToRight, "Hungarian")
 
232
    LNG("is_IS",RS2::locLeftToRight, "Icelandic")
 
233
    LNG("id_ID",RS2::locLeftToRight, "Indonesian")
 
234
    LNG("ia"   ,RS2::locLeftToRight, "Interlingua")
 
235
    LNG("ie"   ,RS2::locLeftToRight, "Interlingue")
 
236
    LNG("iu"   ,RS2::locLeftToRight, "Inuktitut")
 
237
    LNG("ik"   ,RS2::locLeftToRight, "Inupiak")
 
238
    LNG("ga_IE",RS2::locLeftToRight, "Irish")
 
239
    LNG("it_IT",RS2::locLeftToRight, "Italian")
 
240
    LNG("it_CH",RS2::locLeftToRight, "Italian (Swiss)")
 
241
    LNG("ja_JP",RS2::locLeftToRight, "Japanese")
 
242
    LNG("jw"   ,RS2::locLeftToRight, "Javanese")
 
243
    LNG("kn"   ,RS2::locLeftToRight, "Kannada")
 
244
    LNG("ks"   ,RS2::locLeftToRight, "Kashmiri")
 
245
    LNG("ks_IN",RS2::locLeftToRight, "Kashmiri (India)")
 
246
    LNG("kk"   ,RS2::locLeftToRight, "Kazakh")
 
247
    LNG("kw_GB",RS2::locLeftToRight, "Kernewek")
 
248
    LNG("rw"   ,RS2::locLeftToRight, "Kinyarwanda")
 
249
    LNG("ky"   ,RS2::locLeftToRight, "Kirghiz")
 
250
    LNG("rn"   ,RS2::locLeftToRight, "Kirundi")
 
251
    LNG(""     ,RS2::locLeftToRight, "Konkani")
 
252
    LNG("ko_KR",RS2::locLeftToRight, "Korean")
 
253
    LNG("ku_TR",RS2::locLeftToRight, "Kurdish")
 
254
    LNG("lo"   ,RS2::locLeftToRight, "Laothian")
 
255
    LNG("la"   ,RS2::locLeftToRight, "Latin")
 
256
    LNG("lv_LV",RS2::locLeftToRight, "Latvian")
 
257
    LNG("ln"   ,RS2::locLeftToRight, "Lingala")
 
258
    LNG("lt_LT",RS2::locLeftToRight, "Lithuanian")
 
259
    LNG("mk_MK",RS2::locLeftToRight, "Macedonian")
 
260
    LNG("mg"   ,RS2::locLeftToRight, "Malagasy")
 
261
    LNG("ms_MY",RS2::locLeftToRight, "Malay")
 
262
    LNG("ml"   ,RS2::locLeftToRight, "Malayalam")
 
263
    LNG("ms_BN",RS2::locLeftToRight, "Malay (Brunei Darussalam)")
 
264
    LNG("ms_MY",RS2::locLeftToRight, "Malay (Malaysia)")
 
265
    LNG("mt_MT",RS2::locLeftToRight, "Maltese")
 
266
    LNG(""     ,RS2::locLeftToRight, "Manipuri")
 
267
    LNG("mi"   ,RS2::locLeftToRight, "Maori")
 
268
    LNG("mr_IN",RS2::locLeftToRight, "Marathi")
 
269
    LNG("mo"   ,RS2::locLeftToRight, "Moldavian")
 
270
    LNG("mn"   ,RS2::locLeftToRight, "Mongolian")
 
271
    LNG("na"   ,RS2::locLeftToRight, "Nauru")
 
272
    LNG("ne_NP",RS2::locLeftToRight, "Nepali")
 
273
    LNG("ne_IN",RS2::locLeftToRight, "Nepali (India)")
 
274
    LNG("nb_NO",RS2::locLeftToRight, "Norwegian (Bokmal)")
 
275
    LNG("nn_NO",RS2::locLeftToRight, "Norwegian (Nynorsk)")
 
276
    LNG("oc"   ,RS2::locLeftToRight, "Occitan")
 
277
    LNG("or"   ,RS2::locLeftToRight, "Oriya")
 
278
    LNG("om"   ,RS2::locLeftToRight, "(Afan) Oromo")
 
279
    LNG("ps"   ,RS2::locLeftToRight, "Pashto, Pushto")
 
280
    LNG("pl_PL",RS2::locLeftToRight, "Polish")
 
281
    LNG("pt_PT",RS2::locLeftToRight, "Portuguese")
 
282
    LNG("pt_BR",RS2::locLeftToRight, "Portuguese (Brazilian)")
 
283
    LNG("pa"   ,RS2::locLeftToRight, "Punjabi")
 
284
    LNG("qu"   ,RS2::locLeftToRight, "Quechua")
 
285
    LNG("rm"   ,RS2::locLeftToRight, "Rhaeto-Romance")
 
286
    LNG("ro_RO",RS2::locLeftToRight, "Romanian")
 
287
    LNG("ru_RU",RS2::locLeftToRight, "Russian")
 
288
    LNG("ru_UA",RS2::locLeftToRight, "Russian (Ukraine)")
 
289
    LNG("sm"   ,RS2::locLeftToRight, "Samoan")
 
290
    LNG("sg"   ,RS2::locLeftToRight, "Sangho")
 
291
    LNG("sa"   ,RS2::locLeftToRight, "Sanskrit")
 
292
    LNG("gd"   ,RS2::locLeftToRight, "Scots Gaelic")
 
293
    LNG("se_NO",RS2::locLeftToRight, "Northern Sami")
 
294
    LNG("sr_SR",RS2::locLeftToRight, "Serbian")
 
295
    LNG("sr_SR",RS2::locLeftToRight, "Serbian (Cyrillic)")
 
296
    LNG("sr_SR@latin",RS2::locLeftToRight, "Serbian (Latin)")
 
297
    LNG("sr_YU",RS2::locLeftToRight, "Serbian (Cyrillic)")
 
298
    LNG("sr_YU@latin",RS2::locLeftToRight, "Serbian (Latin)")
 
299
    LNG("sh"   ,RS2::locLeftToRight, "Serbo-Croatian")
 
300
    LNG("st"   ,RS2::locLeftToRight, "Sesotho")
 
301
    LNG("tn"   ,RS2::locLeftToRight, "Setswana")
 
302
    LNG("sn"   ,RS2::locLeftToRight, "Shona")
 
303
    LNG("sd"   ,RS2::locLeftToRight, "Sindhi")
 
304
    LNG("si"   ,RS2::locLeftToRight, "Sinhalese")
 
305
    LNG("ss"   ,RS2::locLeftToRight, "Siswati")
 
306
    LNG("sk_SK",RS2::locLeftToRight, "Slovak")
 
307
    LNG("sl_SI",RS2::locLeftToRight, "Slovenian")
 
308
    LNG("so"   ,RS2::locLeftToRight, "Somali")
 
309
    LNG("es_ES",RS2::locLeftToRight, "Spanish")
 
310
    LNG("es_AR",RS2::locLeftToRight, "Spanish (Argentina)")
 
311
    LNG("es_BO",RS2::locLeftToRight, "Spanish (Bolivia)")
 
312
    LNG("es_CL",RS2::locLeftToRight, "Spanish (Chile)")
 
313
    LNG("es_CO",RS2::locLeftToRight, "Spanish (Colombia)")
 
314
    LNG("es_CR",RS2::locLeftToRight, "Spanish (Costa Rica)")
 
315
    LNG("es_DO",RS2::locLeftToRight, "Spanish (Dominican republic)")
 
316
    LNG("es_EC",RS2::locLeftToRight, "Spanish (Ecuador)")
 
317
    LNG("es_SV",RS2::locLeftToRight, "Spanish (El Salvador)")
 
318
    LNG("es_GT",RS2::locLeftToRight, "Spanish (Guatemala)")
 
319
    LNG("es_HN",RS2::locLeftToRight, "Spanish (Honduras)")
 
320
    LNG("es_MX",RS2::locLeftToRight, "Spanish (Mexican)")
 
321
    LNG("es_ES",RS2::locLeftToRight, "Spanish (Modern)")
 
322
    LNG("es_NI",RS2::locLeftToRight, "Spanish (Nicaragua)")
 
323
    LNG("es_PA",RS2::locLeftToRight, "Spanish (Panama)")
 
324
    LNG("es_PY",RS2::locLeftToRight, "Spanish (Paraguay)")
 
325
    LNG("es_PE",RS2::locLeftToRight, "Spanish (Peru)")
 
326
    LNG("es_PR",RS2::locLeftToRight, "Spanish (Puerto Rico)")
 
327
    LNG("es_UY",RS2::locLeftToRight, "Spanish (Uruguay)")
 
328
    LNG("es_US",RS2::locLeftToRight, "Spanish (U.S.)")
 
329
    LNG("es_VE",RS2::locLeftToRight, "Spanish (Venezuela)")
 
330
    LNG("su"   ,RS2::locLeftToRight, "Sundanese")
 
331
    LNG("sw_KE",RS2::locLeftToRight, "Swahili")
 
332
    LNG("sv_SE",RS2::locLeftToRight, "Swedish")
 
333
    LNG("sv_FI",RS2::locLeftToRight, "Swedish (Finland)")
 
334
    LNG("tl_PH",RS2::locLeftToRight, "Tagalog")
 
335
    LNG("tg"   ,RS2::locLeftToRight, "Tajik")
 
336
    LNG("ta"   ,RS2::locLeftToRight, "Tamil")
 
337
    LNG("tt"   ,RS2::locLeftToRight, "Tatar")
 
338
    LNG("te"   ,RS2::locLeftToRight, "Telugu")
 
339
    LNG("th_TH",RS2::locLeftToRight, "Thai")
 
340
    LNG("bo"   ,RS2::locLeftToRight, "Tibetan")
 
341
    LNG("ti"   ,RS2::locLeftToRight, "Tigrinya")
 
342
    LNG("to"   ,RS2::locLeftToRight, "Tonga")
 
343
    LNG("ts"   ,RS2::locLeftToRight, "Tsonga")
 
344
    LNG("tr_TR",RS2::locLeftToRight, "Turkish")
 
345
    LNG("tk"   ,RS2::locLeftToRight, "Turkmen")
 
346
    LNG("tw"   ,RS2::locLeftToRight, "Twi")
 
347
    LNG("ug"   ,RS2::locLeftToRight, "Uighur")
 
348
    LNG("uk",RS2::locLeftToRight, "Ukrainian")
 
349
    LNG("ur"   ,RS2::locLeftToRight, "Urdu")
 
350
    LNG("ur_IN",RS2::locLeftToRight, "Urdu (India)")
 
351
    LNG("ur_PK",RS2::locLeftToRight, "Urdu (Pakistan)")
 
352
    LNG("uz"   ,RS2::locLeftToRight, "Uzbek")
 
353
    LNG("uz"   ,RS2::locLeftToRight, "Uzbek (Cyrillic)")
 
354
    LNG("uz"   ,RS2::locLeftToRight, "Uzbek (Latin)")
 
355
    LNG("ca_ES@valencia",RS2::locLeftToRight, "Valencian")
 
356
    LNG("vi_VN",RS2::locLeftToRight, "Vietnamese")
 
357
    LNG("vo"   ,RS2::locLeftToRight, "Volapuk")
 
358
    LNG("cy"   ,RS2::locLeftToRight, "Welsh")
 
359
    LNG("wo"   ,RS2::locLeftToRight, "Wolof")
 
360
    LNG("xh"   ,RS2::locLeftToRight, "Xhosa")
 
361
    LNG("yi"   ,RS2::locLeftToRight, "Yiddish")
 
362
    LNG("yo"   ,RS2::locLeftToRight, "Yoruba")
 
363
    LNG("za"   ,RS2::locLeftToRight, "Zhuang")
 
364
    LNG("zu"   ,RS2::locLeftToRight, "Zulu")
 
365
}
 
366
 
 
367
 
 
368
/**
 
369
 * Loads a different translation for the application GUI.
 
370
 *
 
371
 *fixme, need to support command language
 
372
 */
 
373
void RS_System::loadTranslation(const QString& lang, const QString& /*langCmd*/) {
 
374
    static QTranslator* tQt = NULL;
 
375
    static QTranslator* tLibreCAD = NULL;
 
376
    static QTranslator* tPlugIns = NULL;
 
377
 
 
378
    //make translation filenames case insensitive, #276
 
379
    QString langLower("");
 
380
    QString langUpper("");
 
381
    int i0 = lang.indexOf('_');
 
382
    if( i0 >= 2 && lang.size() - i0 >= 2 ){
 
383
        //contains region code
 
384
        langLower = lang.left(i0) + '_' + lang.mid(i0+1).toLower();
 
385
        langUpper = lang.left(i0) + '_' + lang.mid(i0+1).toUpper();
 
386
    }else{
 
387
        langLower = lang;
 
388
        langUpper.clear();
 
389
    }
 
390
    // search in various directories for translations
 
391
    QStringList lst = getDirectoryList("qm");
 
392
 
 
393
    RS_SETTINGS->beginGroup("/Paths");
 
394
    lst += (RS_SETTINGS->readEntry("/Translations", "")).split(";", QString::SkipEmptyParts);
 
395
    RS_SETTINGS->endGroup();
 
396
 
 
397
    if( tLibreCAD != NULL) {
 
398
        qApp->removeTranslator(tLibreCAD);
 
399
        delete tLibreCAD;
 
400
    }
 
401
    if( tPlugIns != NULL) {
 
402
        qApp->removeTranslator(tPlugIns);
 
403
        delete tPlugIns;
 
404
    }
 
405
    if( tQt != NULL) {
 
406
        qApp->removeTranslator(tQt);
 
407
        delete tQt;
 
408
    }
 
409
    QString langFileLower = "librecad_" + langLower + ".qm",
 
410
            langFileUpper = "librecad_" + langUpper + ".qm",
 
411
            langPlugInsLower = "plugins_" + langLower + ".qm",
 
412
            langPlugInsUpper = "plugins_" + langUpper + ".qm",
 
413
            langQtLower = "qt_" + langLower + ".qm",
 
414
            langQtUpper = "qt_" + langUpper + ".qm";
 
415
    QTranslator* t = new QTranslator(0);
 
416
    for (QStringList::Iterator it = lst.begin();
 
417
         it!=lst.end();
 
418
         ++it) {
 
419
 
 
420
        // load LibreCAD translations
 
421
        if( NULL == tLibreCAD) {
 
422
            if( t->load(langFileLower, *it)==true
 
423
                    || (  ! langUpper.isEmpty()
 
424
                          &&    t->load(langFileUpper, *it)==true)) {
 
425
                tLibreCAD = t;
 
426
                qApp->installTranslator(tLibreCAD);
 
427
                t = new QTranslator(0);
 
428
            }
 
429
        }
 
430
 
 
431
        // load PlugIns translations
 
432
        if( NULL == tPlugIns) {
 
433
            if( t->load(langPlugInsLower, *it)==true
 
434
                    || (  ! langUpper.isEmpty()
 
435
                          &&    t->load(langPlugInsUpper, *it)==true)) {
 
436
                tPlugIns = t;
 
437
                qApp->installTranslator(tPlugIns);
 
438
                t = new QTranslator(0);
 
439
            }
 
440
        }
 
441
 
 
442
        // load Qt standard dialog translations
 
443
        if( NULL == tQt) {
 
444
            if( t->load(langQtLower, *it)==true
 
445
                    || (  ! langUpper.isEmpty()
 
446
                          &&    t->load(langQtUpper, *it)==true)) {
 
447
                tQt = t;
 
448
                qApp->installTranslator(tQt);
 
449
                t = new QTranslator(0);
 
450
            }
 
451
        }
 
452
        if( NULL != tLibreCAD && NULL != tPlugIns && NULL != tQt) {
 
453
            break;
 
454
        }
 
455
    }
 
456
    if( NULL != t) {
 
457
        delete t;
 
458
    }
 
459
}
 
460
 
 
461
 
 
462
 
 
463
/**
 
464
 * Checks if the system has been initialized and prints a warning
 
465
 * otherwise to stderr.
 
466
 */
 
467
bool RS_System::checkInit() {
 
468
    if (!initialized) {
 
469
        RS_DEBUG->print(RS_Debug::D_WARNING,
 
470
                        "RS_System::checkInit: System not initialized.\n"
 
471
            "Use RS_SYSTEM->init(appname, appdirname) to do so.");
 
472
    }
 
473
    return initialized;
 
474
}
 
475
 
 
476
 
 
477
 
 
478
 
 
479
/**
 
480
 * Creates all given directories in the user's home.
 
481
 */
 
482
bool RS_System::createPaths(const QString& directory) {
 
483
    QDir dir;
 
484
    dir.cd(QDir::homePath());
 
485
    dir.mkpath(directory);
 
486
    return true;
 
487
}
 
488
 
 
489
 
 
490
/**
 
491
 * Create if not exist and return the Application data directory.
 
492
 * In OS_WIN32 "c:\documents&settings\<user>\local configuration\application data\LibreCAD"
 
493
 * In OS_MAC "???"
 
494
 * In OS_LINUX "/home/<user>/.local/share/data/LibreCAD"
 
495
 *
 
496
 * @return Application data directory.
 
497
 */
 
498
QString RS_System::getAppDataDir() {
 
499
    QString appData = 
 
500
#if QT_VERSION >= 0x050000
 
501
        QStandardPaths::writableLocation(QStandardPaths::DataLocation);
 
502
#else
 
503
        QDesktopServices::storageLocation(QDesktopServices::DataLocation) ;
 
504
#endif 
 
505
    QDir dir(appData);
 
506
    if (!dir.exists()) {
 
507
        if (!dir.mkpath(appData))
 
508
            return QString();
 
509
    }
 
510
    return appData;
 
511
}
 
512
 
 
513
 
 
514
/**
 
515
 * Searches for files in an application shared directory in the given
 
516
 * subdirectory with the given extension.
 
517
 *
 
518
 * @return List of the absolute paths of the files found.
 
519
 */
 
520
QStringList RS_System::getFileList(const QString& subDirectory,
 
521
                                     const QString& fileExtension) {
 
522
 
 
523
    checkInit();
 
524
 
 
525
        RS_DEBUG->print("RS_System::getFileList: subdirectory %s ", subDirectory.toLatin1().data());
 
526
        RS_DEBUG->print("RS_System::getFileList: appDirName %s ", appDirName.toLatin1().data());
 
527
        RS_DEBUG->print("RS_System::getFileList: getCurrentDir %s ", getCurrentDir().toLatin1().data());
 
528
 
 
529
 
 
530
    QStringList dirList = getDirectoryList(subDirectory);
 
531
 
 
532
    QStringList fileList;
 
533
    QString path;
 
534
    QDir dir;
 
535
 
 
536
    for (QStringList::Iterator it = dirList.begin();
 
537
            it!=dirList.end();
 
538
            ++it ) {
 
539
 
 
540
        //path = QString(*it) + "/" + subDirectory;
 
541
        path = QString(*it);
 
542
        dir = QDir(path);
 
543
 
 
544
        if (dir.exists() && dir.isReadable()) {
 
545
            QStringList files = dir.entryList( QStringList("*." + fileExtension) );
 
546
            for (QStringList::Iterator it2 = files.begin();
 
547
                    it2!=files.end();
 
548
                    it2++) {
 
549
 
 
550
                fileList += path + "/" + (*it2);
 
551
            }
 
552
        }
 
553
    }
 
554
 
 
555
    return fileList;
 
556
}
 
557
 
 
558
 
 
559
 
 
560
/**
 
561
 * @return List of all directories in subdirectory 'subDirectory' in
 
562
 * all possible QCad directories.
 
563
 */
 
564
QStringList RS_System::getDirectoryList(const QString& _subDirectory) {
 
565
    QStringList dirList;
 
566
 
 
567
    QString subDirectory=QDir::fromNativeSeparators(_subDirectory);
 
568
 
 
569
#if QT_VERSION < 0x040400 && defined(_MSC_VER)
 
570
        dirList.append(emu_qt44_storageLocationDocuments() + "/" + 
 
571
                       appDirName + "/" + 
 
572
                       subDirectory);
 
573
#else // QT_VERSION > 0x040400 or _MSC_VER not defined (!) 
 
574
 
 
575
#ifdef Q_OS_MAC
 
576
#if QT_VERSION >= 0x050000
 
577
         dirList.append(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/" + appDirName + "/" + subDirectory);
 
578
#else
 
579
        dirList.append(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/" + appDirName + "/" + subDirectory);
 
580
#endif
 
581
#endif // Q_OS_MAC
 
582
                
 
583
#ifdef Q_OS_WIN32
 
584
#if QT_VERSION >= 0x050000
 
585
        dirList.append(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/" + appDirName + "/" + subDirectory);
 
586
#else
 
587
        dirList.append(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/" + appDirName + "/" + subDirectory);
 
588
#endif
 
589
#endif // Q_OS_WIN32
 
590
                
 
591
    // Unix home directory, it's old style but some people might have stuff there.
 
592
    dirList.append(getHomeDir() + "/." + appDirName + "/" + subDirectory);
 
593
#endif // QT_VERSION < 0x040400 && defined(_MSC_VER)
 
594
 
 
595
        //local (application) directory has priority over other dirs:
 
596
        if (!appDir.isEmpty() && appDir!="/" && appDir!=getHomeDir()) {
 
597
                if( appDir != getCurrentDir() && subDirectory != QString("plugins")) {// 17 Aug, 2011, Dongxu Li, do not look for plugins in the current folder, we should install plugins to system or ~/.LibreCAD/plugins/
 
598
            dirList.append(appDir + "/" + subDirectory);
 
599
            }
 
600
        }
 
601
 
 
602
        // Ubuntu
 
603
        dirList.append("/usr/share/doc/" + appDirName + "/" + subDirectory);
 
604
 
 
605
        // Redhat style:
 
606
        dirList.append("/usr/share/" + appDirName + "/" + subDirectory);
 
607
 
 
608
        // Others, RVT April 25, 2011 removed, doesn anybody use that still?
 
609
        // dirList.append("/usr/X11R6/share/" + appDirName + "/" + subDirectory);
 
610
 
 
611
 
 
612
#ifdef Q_OS_MAC
 
613
    // Apple uses the resource directory
 
614
    if (!appDir.isEmpty() && appDir!="/") {
 
615
        dirList.append(appDir + "/../Resources/" + subDirectory);
 
616
    }
 
617
#endif
 
618
 
 
619
#ifndef Q_OS_MAC
 
620
        // Add support directory if librecad is run-in-place,
 
621
        // not for Apple because it uses resources this is more for unix systems
 
622
        dirList.append(appDir + "/resources/" + subDirectory);
 
623
#endif
 
624
 
 
625
    // Individual directories:
 
626
    RS_SETTINGS->beginGroup("/Paths");
 
627
    if (subDirectory=="fonts") {
 
628
        dirList += (RS_SETTINGS->readEntry("/Fonts", "")).split(QRegExp("[;]"),
 
629
                                                        QString::SkipEmptyParts);
 
630
    } else if (subDirectory=="patterns") {
 
631
        dirList += (RS_SETTINGS->readEntry("/Patterns", "")).split(QRegExp("[;]"),
 
632
                                                        QString::SkipEmptyParts);
 
633
    } else if (subDirectory.startsWith("scripts")) {
 
634
        dirList += (RS_SETTINGS->readEntry("/Scripts", "")).split(QRegExp("[;]"),
 
635
                                                        QString::SkipEmptyParts);
 
636
    } else if (subDirectory.startsWith("library")) {
 
637
        dirList += (RS_SETTINGS->readEntry("/Library", "")).split(QRegExp("[;]"),
 
638
                                                        QString::SkipEmptyParts);
 
639
    } else if (subDirectory.startsWith("po")) {
 
640
        dirList += (RS_SETTINGS->readEntry("/Translations", "")).split(QRegExp("[;]"),
 
641
                                                        QString::SkipEmptyParts);
 
642
    }
 
643
    RS_SETTINGS->endGroup();
 
644
 
 
645
    QStringList ret;
 
646
 
 
647
    RS_DEBUG->print("RS_System::getDirectoryList: Paths:");
 
648
    for (QStringList::Iterator it = dirList.begin();
 
649
            it!=dirList.end(); ++it ) {
 
650
 
 
651
        if (QFileInfo(*it).isDir()) {
 
652
            ret += (*it);
 
653
            RS_DEBUG->print( (*it).toLatin1() );
 
654
        }
 
655
    }
 
656
 
 
657
    return ret;
 
658
}
 
659
 
 
660
 
 
661
 
 
662
/**
 
663
 * Converts a language string to a symbol (e.g. Deutsch or German to 'de').
 
664
 * Languages taken from RFC3066
 
665
 */
 
666
QString RS_System::languageToSymbol(const QString& lang) {
 
667
        int i1=lang.indexOf(' ');
 
668
    QString l = lang;
 
669
        if(i1 >= 2){
 
670
                l=lang.mid(0,i1);
 
671
        }
 
672
        return l;
 
673
 
 
674
//    RS_Locale *locale;
 
675
//    foreach (locale, *RS_SYSTEM->allKnownLocales) {
 
676
//        if (locale->getName().toLower()==l) {
 
677
//            return locale->getCanonical();
 
678
//        }
 
679
//    }
 
680
 
 
681
//    return "";
 
682
}
 
683
 
 
684
 
 
685
 
 
686
/**
 
687
 * Converst a locale code into a readable string
 
688
 * (e.g. 'de' to 'German Deutsch'
 
689
 * (e.g. 'en_au' to 'English (Australia)'
 
690
 */
 
691
QString RS_System::symbolToLanguage(const QString& symb) {
 
692
    RS_Locale loc(symb);
 
693
    QString ret;
 
694
#if QT_VERSION >= 0x040800
 
695
    if( symb.contains(QRegExp("^en"))){
 
696
#endif
 
697
        ret=RS_Locale::languageToString(loc.language());
 
698
        if( symb.contains('_') ) {
 
699
            ret +=" ("+RS_Locale::countryToString(loc.country())+')';
 
700
        }
 
701
#if QT_VERSION >= 0x040800
 
702
    }else{
 
703
        ret=RS_Locale::languageToString(loc.language())+' '+loc.nativeLanguageName();
 
704
        if( symb.contains('_') ) {
 
705
            ret +=" ("+RS_Locale::countryToString(loc.country())+' '+ loc.nativeCountryName()+')';
 
706
        }
 
707
    }
 
708
#endif
 
709
 
 
710
//    std::cout<<__FILE__<<" : "<<__FUNCTION__<<" :  line "<<__LINE__<<" :  symb="<<qPrintable(symb)<<" name="<<qPrintable(ret)<<std::endl;
 
711
 
 
712
        return ret;
 
713
 
 
714
}
 
715
 
 
716
 
 
717
 
 
718
/**
 
719
 * Tries to convert the given encoding string to an encoding Qt knows.
 
720
 */
 
721
QString RS_System::getEncoding(const QString& str) {
 
722
    QString l=str.toLower();
 
723
 
 
724
    if (l=="latin1" || l=="ansi_1252" || l=="iso-8859-1" ||
 
725
            l=="cp819" || l=="csiso" || l=="ibm819" || l=="iso_8859-1" ||
 
726
            l=="iso8859-1" || l=="iso-ir-100" || l=="l1") {
 
727
        return "Latin1";
 
728
    } else if (l=="big5" || l=="ansi_950" || l=="cn-big5" || l=="csbig5" ||
 
729
               l=="x-x-big5") {
 
730
        return "Big5";
 
731
    } else if (l=="big5-hkscs") {
 
732
        return "Big5-HKSCS";
 
733
    } else if (l=="eucjp" || l=="euc-jp" || l=="cseucpkdfmtjapanese" ||
 
734
               l=="x-euc" || l=="x-euc-jp") {
 
735
        return "eucJP";
 
736
    } else if (l=="euckr") {
 
737
        return "eucKR";
 
738
    } else if (l=="gb2312" || l=="gb2312" || l=="chinese" || l=="cn-gb" ||
 
739
               l=="csgb2312" || l=="csgb231280" || l=="csiso58gb231280" ||
 
740
               l=="gb_2312-80" || l=="gb231280" || l=="gb2312-80" || l=="gbk" ||
 
741
               l=="iso-ir-58") {
 
742
        return "GB2312";
 
743
    } else if (l=="gbk") {
 
744
        return "GBK";
 
745
    } else if (l=="gb18030") {
 
746
        return "GB18030";
 
747
    } else if (l=="jis7") {
 
748
        return "JIS7";
 
749
    } else if (l=="shift-jis" || l=="ansi_932" || l=="shift_jis" || l=="csShiftJIS" ||
 
750
               l=="cswindows31j" || l=="ms_kanji" || l=="x-ms-cp932" || l=="x-sjis") {
 
751
        return "Shift-JIS";
 
752
    } else if (l=="tscii") {
 
753
        return "TSCII";
 
754
    } else if (l=="utf88-bit") {
 
755
        return "utf88-bit";
 
756
    } else if (l=="utf16") {
 
757
        return "utf16";
 
758
    } else if (l=="utf8" || l=="utf-8") {
 
759
        return "utf-8";
 
760
    } else if (l=="koi8-r") {
 
761
        return "KOI8-R";
 
762
    } else if (l=="koi8-u") {
 
763
        return "KOI8-U";
 
764
    } else if (l=="iso8859-1") {
 
765
        return "ISO8859-1";
 
766
    } else if (l=="iso8859-2") {
 
767
        return "ISO8859-2";
 
768
    } else if (l=="iso8859-3") {
 
769
        return "ISO8859-3";
 
770
    } else if (l=="iso8859-4" || l=="ansi_1257") {
 
771
        return "ISO8859-4";
 
772
    } else if (l=="iso8859-5") {
 
773
        return "ISO8859-5";
 
774
    } else if (l=="iso8859-6" || l=="ansi_1256") {
 
775
        return "ISO8859-6";
 
776
    } else if (l=="iso8859-7" || l=="ansi_1253") {
 
777
        return "ISO8859-7";
 
778
    } else if (l=="iso8859-8") {
 
779
        return "ISO8859-8";
 
780
    } else if (l=="iso8859-8-i" || l=="ansi_1255") {
 
781
        return "ISO8859-8-i";
 
782
    } else if (l=="iso8859-9" || l=="ansi_1254") {
 
783
        return "ISO8859-9";
 
784
    } else if (l=="iso8859-10") {
 
785
        return "ISO8859-10";
 
786
    } else if (l=="iso8859-13") {
 
787
        return "ISO8859-13";
 
788
    } else if (l=="iso8859-14") {
 
789
        return "ISO8859-14";
 
790
    } else if (l=="iso8859-15") {
 
791
        return "ISO8859-15";
 
792
    } else if (l=="ibm 850") {
 
793
        return "IBM 850";
 
794
    } else if (l=="ibm 866") {
 
795
        return "IBM 866";
 
796
    } else if (l=="cp874") {
 
797
        return "CP874";
 
798
    } else if (l=="cp1250") {
 
799
        return "CP1250";
 
800
    } else if (l=="cp1251" || l=="ansi_1251") {
 
801
        return "CP1251";
 
802
    } else if (l=="cp1252") {
 
803
        return "CP1252";
 
804
    } else if (l=="cp1253") {
 
805
        return "CP1253";
 
806
    } else if (l=="cp1254") {
 
807
        return "CP1254";
 
808
    } else if (l=="cp1255") {
 
809
        return "CP1255";
 
810
    } else if (l=="cp1256") {
 
811
        return "CP1256";
 
812
    } else if (l=="cp1257") {
 
813
        return "CP1257";
 
814
    } else if (l=="cp1258") {
 
815
        return "CP1258";
 
816
    } else if (l=="apple roman") {
 
817
        return "Apple Roman";
 
818
    } else if (l=="tis-620") {
 
819
        return "TIS-620";
 
820
    }
 
821
 
 
822
    return "latin1";
 
823
}
 
824
 
 
825
 
 
826
/** Returns ISO code for given locale. Needed for win32 to convert
 
827
 from system encodings.
 
828
 Locale names mostly copied from XFree86.
 
829
 
 
830
 The code may be incomplete (chinese/japanese locales, etc.)
 
831
 
 
832
 2004-05-13, J Staniek
 
833
*/
 
834
static QMap<QByteArray,QByteArray> loc_map;
 
835
 
 
836
QByteArray RS_System::localeToISO(const QByteArray& locale) {
 
837
    if (loc_map.isEmpty()) {
 
838
        loc_map["croatian"]="ISO8859-2";
 
839
        loc_map["cs"]="ISO8859-2";
 
840
        loc_map["cs_CS"]="ISO8859-2";
 
841
        loc_map["cs_CZ"]="ISO8859-2";
 
842
        loc_map["cz"]="ISO8859-2";
 
843
        loc_map["cz_CZ"]="ISO8859-2";
 
844
        loc_map["czech"]="ISO8859-2";
 
845
        loc_map["hr"]="ISO8859-2";
 
846
        loc_map["hr_HR"]="ISO8859-2";
 
847
        loc_map["hu"]="ISO8859-2";
 
848
        loc_map["hu_HU"]="ISO8859-2";
 
849
        loc_map["hungarian"]="ISO8859-2";
 
850
        loc_map["pl"]="ISO8859-2";
 
851
        loc_map["pl_PL"]="ISO8859-2";
 
852
        loc_map["polish"]="ISO8859-2";
 
853
        loc_map["ro"]="ISO8859-2";
 
854
        loc_map["ro_RO"]="ISO8859-2";
 
855
        loc_map["rumanian"]="ISO8859-2";
 
856
        loc_map["serbocroatian"]="ISO8859-2";
 
857
        loc_map["sh"]="ISO8859-2";
 
858
        loc_map["sh_SP"]="ISO8859-2";
 
859
        loc_map["sh_YU"]="ISO8859-2";
 
860
        loc_map["sk"]="ISO8859-2";
 
861
        loc_map["sk_SK"]="ISO8859-2";
 
862
        loc_map["sl"]="ISO8859-2";
 
863
        loc_map["sl_CS"]="ISO8859-2";
 
864
        loc_map["sl_SI"]="ISO8859-2";
 
865
        loc_map["slovak"]="ISO8859-2";
 
866
        loc_map["slovene"]="ISO8859-2";
 
867
        loc_map["sr_SP"]="ISO8859-2";
 
868
 
 
869
        loc_map["eo"]="ISO8859-3";
 
870
 
 
871
        loc_map["ee"]="ISO8859-4";
 
872
        loc_map["ee_EE"]="ISO8859-4";
 
873
 
 
874
        loc_map["mk"]="ISO8859-5";
 
875
        loc_map["mk_MK"]="ISO8859-5";
 
876
        loc_map["sp"]="ISO8859-5";
 
877
        loc_map["sp_YU"]="ISO8859-5";
 
878
 
 
879
        loc_map["ar_AA"]="ISO8859-6";
 
880
        loc_map["ar_SA"]="ISO8859-6";
 
881
        loc_map["arabic"]="ISO8859-6";
 
882
 
 
883
        loc_map["el"]="ISO8859-7";
 
884
        loc_map["el_GR"]="ISO8859-7";
 
885
        loc_map["greek"]="ISO8859-7";
 
886
 
 
887
        loc_map["hebrew"]="ISO8859-8";
 
888
        loc_map["he"]="ISO8859-8";
 
889
        loc_map["he_IL"]="ISO8859-8";
 
890
        loc_map["iw"]="ISO8859-8";
 
891
        loc_map["iw_IL"]="ISO8859-8";
 
892
 
 
893
        loc_map["tr"]="ISO8859-9";
 
894
        loc_map["tr_TR"]="ISO8859-9";
 
895
        loc_map["turkish"]="ISO8859-9";
 
896
 
 
897
        loc_map["lt"]="ISO8859-13";
 
898
        loc_map["lt_LT"]="ISO8859-13";
 
899
        loc_map["lv"]="ISO8859-13";
 
900
        loc_map["lv_LV"]="ISO8859-13";
 
901
 
 
902
        loc_map["et"]="ISO8859-15";
 
903
        loc_map["et_EE"]="ISO8859-15";
 
904
        loc_map["br_FR"]="ISO8859-15";
 
905
        loc_map["ca_ES"]="ISO8859-15";
 
906
        loc_map["de"]="ISO8859-15";
 
907
        loc_map["de_AT"]="ISO8859-15";
 
908
        loc_map["de_BE"]="ISO8859-15";
 
909
        loc_map["de_DE"]="ISO8859-15";
 
910
        loc_map["de_LU"]="ISO8859-15";
 
911
        loc_map["en_IE"]="ISO8859-15";
 
912
        loc_map["es"]="ISO8859-15";
 
913
        loc_map["es_EC"]="ISO8859-15";
 
914
        loc_map["es_ES"]="ISO8859-15";
 
915
        loc_map["eu_ES"]="ISO8859-15";
 
916
        loc_map["fi"]="ISO8859-15";
 
917
        loc_map["fi_FI"]="ISO8859-15";
 
918
        loc_map["finnish"]="ISO8859-15";
 
919
        loc_map["fr"]="ISO8859-15";
 
920
        loc_map["fr_FR"]="ISO8859-15";
 
921
        loc_map["fr_BE"]="ISO8859-15";
 
922
        loc_map["fr_LU"]="ISO8859-15";
 
923
        loc_map["french"]="ISO8859-15";
 
924
        loc_map["ga_IE"]="ISO8859-15";
 
925
        loc_map["gl_ES"]="ISO8859-15";
 
926
        loc_map["it"]="ISO8859-15";
 
927
        loc_map["it_IT"]="ISO8859-15";
 
928
        loc_map["oc_FR"]="ISO8859-15";
 
929
        loc_map["nl"]="ISO8859-15";
 
930
        loc_map["nl_BE"]="ISO8859-15";
 
931
        loc_map["nl_NL"]="ISO8859-15";
 
932
        loc_map["pt"]="ISO8859-15";
 
933
        loc_map["pt_PT"]="ISO8859-15";
 
934
        loc_map["sv_FI"]="ISO8859-15";
 
935
        loc_map["wa_BE"]="ISO8859-15";
 
936
 
 
937
        loc_map["uk"]="KOI8-U";
 
938
        loc_map["uk_UA"]="KOI8-U";
 
939
        loc_map["ru_YA"]="KOI8-U";
 
940
        loc_map["ukrainian"]="KOI8-U";
 
941
 
 
942
        loc_map["be"]="KOI8-R";
 
943
        loc_map["be_BY"]="KOI8-R";
 
944
        loc_map["bg"]="KOI8-R";
 
945
        loc_map["bg_BG"]="KOI8-R";
 
946
        loc_map["bulgarian"]="KOI8-R";
 
947
        loc_map["ba_RU"]="KOI8-R";
 
948
        loc_map["ky"]="KOI8-R";
 
949
        loc_map["ky_KG"]="KOI8-R";
 
950
        loc_map["kk"]="KOI8-R";
 
951
        loc_map["kk_KZ"]="KOI8-R";
 
952
    }
 
953
    QByteArray l = loc_map[locale];
 
954
    if (l.isEmpty())
 
955
        return "ISO8859-1";
 
956
    return l;
 
957
}