2017-08-05 15:20:02 +10:00
|
|
|
/****************************************
|
|
|
|
*
|
|
|
|
* theShell - Desktop Environment
|
|
|
|
* Copyright (C) 2017 Victor Tran
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* *************************************/
|
|
|
|
|
2017-04-16 22:46:08 +10:00
|
|
|
#ifndef INTERNATIONALISATION_H
|
|
|
|
#define INTERNATIONALISATION_H
|
|
|
|
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QSettings>
|
|
|
|
|
2017-07-04 23:21:30 +10:00
|
|
|
#define TS_VERSION "7.0"
|
|
|
|
|
2017-04-16 22:46:08 +10:00
|
|
|
class Internationalisation {
|
|
|
|
private:
|
|
|
|
static QString tr(const char* text) {
|
2017-07-08 22:03:00 +10:00
|
|
|
QString retval;
|
|
|
|
retval = QApplication::translate("Internationalisation", text);
|
|
|
|
if (strcmp(retval.toUtf8().data(), text) == 0) {
|
|
|
|
retval = QApplication::translate("InfoPaneDropdown", text);
|
|
|
|
}
|
|
|
|
return retval;
|
2017-04-16 22:46:08 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum languageOrder {
|
|
|
|
enUS = 0,
|
|
|
|
enGB,
|
|
|
|
enAU,
|
|
|
|
enNZ,
|
|
|
|
nlNL,
|
|
|
|
viVN,
|
|
|
|
daDK,
|
|
|
|
esES,
|
2017-05-17 20:36:42 +10:00
|
|
|
ruRU,
|
2017-06-06 17:24:45 +10:00
|
|
|
svSE,
|
2017-04-16 23:53:50 +10:00
|
|
|
// Unfinished languages follow
|
2017-04-16 22:46:08 +10:00
|
|
|
jaJP,
|
|
|
|
arSA,
|
|
|
|
zhCN,
|
|
|
|
deDE,
|
2017-04-16 23:53:50 +10:00
|
|
|
frFR,
|
2017-04-16 22:46:08 +10:00
|
|
|
miNZ,
|
2017-08-04 21:18:42 +10:00
|
|
|
ptBR,
|
2017-04-16 22:46:08 +10:00
|
|
|
maxLanguage
|
|
|
|
};
|
|
|
|
|
|
|
|
static void fillLanguageBox(QListWidget* languageBox) {
|
|
|
|
//Clear the box
|
|
|
|
languageBox->clear();
|
|
|
|
|
|
|
|
//Block signals
|
|
|
|
languageBox->blockSignals(true);
|
|
|
|
|
|
|
|
//For the time being, we'll just have hardcoded locales. This should change soon (hopefully)
|
|
|
|
for (int i = 0; i < maxLanguage; i++) {
|
|
|
|
switch (i) {
|
|
|
|
case enUS:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-us"), tr("English") + " (English)"));
|
2017-04-16 22:46:08 +10:00
|
|
|
break;
|
|
|
|
case enGB:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-uk"), tr("English") + " (English)"));
|
2017-04-16 22:46:08 +10:00
|
|
|
break;
|
|
|
|
case enAU:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-au"), tr("English") + " (English)"));
|
2017-04-16 22:46:08 +10:00
|
|
|
break;
|
|
|
|
case enNZ:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-nz"), tr("English") + " (English)"));
|
2017-04-16 22:46:08 +10:00
|
|
|
break;
|
|
|
|
case viVN:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-vn"), tr("Vietnamese") + " (Tiếng Việt)"));
|
2017-04-16 22:46:08 +10:00
|
|
|
break;
|
|
|
|
case daDK:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-dk"), tr("Danish") + " (Dansk) "));
|
2017-04-16 22:46:08 +10:00
|
|
|
break;
|
2017-04-16 23:53:50 +10:00
|
|
|
case nlNL:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-nl"), tr("Dutch") + " (Nederlands) "));
|
2017-04-16 23:53:50 +10:00
|
|
|
break;
|
|
|
|
case esES:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-es"), tr("Spanish") + " (Español) "));
|
2017-04-16 23:53:50 +10:00
|
|
|
break;
|
2017-05-17 20:36:42 +10:00
|
|
|
case ruRU:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-ru"), tr("Russian") + " (русский) "));
|
2017-05-17 20:36:42 +10:00
|
|
|
break;
|
2017-06-06 17:24:45 +10:00
|
|
|
case svSE:
|
2017-08-04 21:18:42 +10:00
|
|
|
languageBox->addItem(new QListWidgetItem(QIcon::fromTheme("flag-se"), tr("Swedish") + " (Svenska) "));
|
2017-06-06 17:24:45 +10:00
|
|
|
break;
|
2017-04-16 22:46:08 +10:00
|
|
|
/*case arSA:
|
|
|
|
languageBox->addItem("[SA] " + tr("Arabic") + " (العربية) ");
|
|
|
|
break;
|
2017-08-04 21:18:42 +10:00
|
|
|
case ptBR:
|
|
|
|
languageBox->addItem("[BR] " + tr("Portuguese") + " (Português) ");
|
|
|
|
break;
|
2017-04-16 22:46:08 +10:00
|
|
|
case zhCN:
|
|
|
|
languageBox->addItem("[CN] " + tr("Chinese") + " (中文) ");
|
|
|
|
break;
|
2017-04-16 23:53:50 +10:00
|
|
|
case frFR:
|
|
|
|
languageBox->addItem("[FR] " + tr("French") + " (Français) ");
|
|
|
|
break;
|
|
|
|
case miNZ:
|
2017-04-16 22:46:08 +10:00
|
|
|
languageBox->addItem("[NZ] " + tr("Māori") + " (Māori) ");
|
|
|
|
break;
|
|
|
|
case jaJP:
|
|
|
|
languageBox->addItem("[JP] " + tr("Japanese") + " (日本語) ");
|
|
|
|
break;
|
|
|
|
case deDE:
|
|
|
|
languageBox->addItem("[DE] " + tr("German") + " (Deutsch) ");
|
|
|
|
break;*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
QString currentLocale = settings.value("locale/language", "en_US").toString();
|
|
|
|
if (currentLocale == "en_US") {
|
|
|
|
languageBox->setCurrentRow(enUS);
|
|
|
|
} else if (currentLocale == "en_GB") {
|
|
|
|
languageBox->setCurrentRow(enGB);
|
|
|
|
} else if (currentLocale == "en_AU") {
|
|
|
|
languageBox->setCurrentRow(enAU);
|
|
|
|
} else if (currentLocale == "en_NZ") {
|
|
|
|
languageBox->setCurrentRow(enNZ);
|
|
|
|
} else if (currentLocale == "vi_VN") {
|
|
|
|
languageBox->setCurrentRow(viVN);
|
|
|
|
} else if (currentLocale == "da_DK") {
|
|
|
|
languageBox->setCurrentRow(daDK);
|
|
|
|
} else if (currentLocale == "pt_BR") {
|
|
|
|
languageBox->setCurrentRow(ptBR);
|
|
|
|
} else if (currentLocale == "ar_SA") {
|
|
|
|
languageBox->setCurrentRow(arSA);
|
|
|
|
} else if (currentLocale == "zh_CN") {
|
|
|
|
languageBox->setCurrentRow(zhCN);
|
|
|
|
} else if (currentLocale == "nl_NL") {
|
|
|
|
languageBox->setCurrentRow(nlNL);
|
|
|
|
} else if (currentLocale == "mi_NZ") {
|
|
|
|
languageBox->setCurrentRow(miNZ);
|
|
|
|
} else if (currentLocale == "ja_JP") {
|
|
|
|
languageBox->setCurrentRow(jaJP);
|
|
|
|
} else if (currentLocale == "de_DE") {
|
|
|
|
languageBox->setCurrentRow(deDE);
|
2017-04-16 23:53:50 +10:00
|
|
|
} else if (currentLocale == "fr_FR") {
|
|
|
|
languageBox->setCurrentRow(frFR);
|
2017-04-16 22:46:08 +10:00
|
|
|
} else if (currentLocale == "es_ES") {
|
|
|
|
languageBox->setCurrentRow(esES);
|
2017-05-17 20:36:42 +10:00
|
|
|
} else if (currentLocale == "ru_RU") {
|
|
|
|
languageBox->setCurrentRow(ruRU);
|
2017-06-06 17:24:45 +10:00
|
|
|
} else if (currentLocale == "sv_SE") {
|
|
|
|
languageBox->setCurrentRow(svSE);
|
2017-04-16 22:46:08 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
//Unblock signals
|
|
|
|
languageBox->blockSignals(false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INTERNATIONALISATION_H
|