Rework Translator

master
Unknown 2019-03-22 03:24:03 +01:00
parent 693301a978
commit ca271e2a38
8 changed files with 223 additions and 213 deletions

View File

@ -32,6 +32,7 @@ set(SOURCES
figuredelegate.cpp
minetestmapperexe.cpp
colorstxtwizard.cpp
translator.cpp
)
set(HEADERS
@ -46,6 +47,7 @@ set(HEADERS
figuredelegate.h
minetestmapperexe.h
colorstxtwizard.h
translator.h
)
set(FORMS

View File

@ -1,4 +1,5 @@
#include "mainwindow.h"
#include "translator.h"
#include <QCoreApplication>
#include <QApplication>
#include <QDebug>
@ -15,23 +16,7 @@ int main(int argc, char *argv[])
// Setup the translators
const QString translationsPath = "./translations/";
QTranslator qtTranslator;
if(qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
a.installTranslator(&qtTranslator);
qDebug()<< QLibraryInfo::location(QLibraryInfo::TranslationsPath);
}
else{
qtTranslator.load("qt_" + QLocale::system().name(),
translationsPath);
a.installTranslator(&qtTranslator);
}
QTranslator translator;
if (translator.load("gui_" + QLocale::system().name(), translationsPath))
a.installTranslator(&translator);
Translator t(QLocale::system());
// Init commandline parser
@ -48,7 +33,7 @@ int main(int argc, char *argv[])
bool portable = parser.isSet(startPortableOption);
MainWindow w(portable, translationsPath, &translator, &qtTranslator);
MainWindow w(portable, &t);
w.show();
return a.exec();

View File

@ -2,19 +2,16 @@
#include "ui_mainwindow.h"
#include <QCompleter>
#include <QDebug>
#include <QDesktopServices>
#include <QDirModel>
#include <QFileDialog>
#include <QStringList>
MainWindow::MainWindow(bool portable, const QString &translationsPath, QTranslator *translator, QTranslator *qtTranslator, QWidget *parent) :
MainWindow::MainWindow(bool portable, Translator *translator, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
translator(translator),
qtTranslator(qtTranslator),
translationsPath(translationsPath)
translator(translator)
{
if(portable){
//Attention: This paths could be non writable locations!
@ -158,41 +155,30 @@ void MainWindow::finishUiInitialisation()
void MainWindow::createLanguageMenu()
{
QActionGroup* langGroup = new QActionGroup(ui->menuLanguage);
langGroup->setExclusive(true);
//langGroup->setExclusive(true);
connect(langGroup, &QActionGroup::triggered, this, &MainWindow::slotLanguageChanged);
QStringList translations = translator->getTranslations();
QLocale::Language defaultLanguage = translator->getCurrentLocale().language();
for (const QString &locale : translations) {
QLocale l = QLocale(locale);
// format systems language
QString defaultLocale = QLocale::system().name(); // e.g. "de_DE"
qDebug()<<"Default locale:"<<defaultLocale;
defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de"
QLocale::Language language = l.language();
qDebug()<<"Lang path "<< translationsPath;
QDir dir(translationsPath);
QStringList fileNames = dir.entryList(QStringList("qt_*.qm"));
for (int i = 0; i < fileNames.size(); ++i) {
// get locale extracted by filename
QString locale;
locale = fileNames[i]; // "qt_de.qm"
locale.truncate(locale.lastIndexOf('.')); // "qt_de"
locale.remove(0, locale.indexOf('_') + 1); // "de"
QString lang = QLocale::languageToString(QLocale(locale).language());
QIcon ico(QString("%1/%2.png").arg(translationsPath).arg(locale));
QString lang = QLocale::languageToString(language);
QIcon ico(QString("%1/%2.png").arg(translator->translationsPath).arg(locale));
QAction *action = new QAction(ico, lang, this);
action->setCheckable(true);
action->setData(locale);
action->setData(l);
ui->menuLanguage->addAction(action);
langGroup->addAction(action);
// set default translators and language checked
if (defaultLocale == locale)
if (defaultLanguage == language)
{
action->setChecked(true);
//loadLanguage(locale);
}
}
}
@ -200,61 +186,34 @@ void MainWindow::createLanguageMenu()
// Called every time, when a menu entry of the language menu is called
void MainWindow::slotLanguageChanged(QAction* action)
{
if(0 != action) {
if(action) {
// load the language dependant on the action content
loadLanguage(action->data().toString());
qDebug() << action->data();
QLocale locale = QLocale(action->data().toLocale());
translator->setLocale(locale);
}
}
void MainWindow::switchTranslator(QTranslator *translator, const QString &prefix, const QLocale &locale)
{
// remove the old translator
qApp->removeTranslator(translator);
qDebug() << "Trying to load language "<< translationsPath << prefix<<locale;
// load the new translator
if(translator->load(locale , "", prefix, translationsPath)){
qDebug() << "Loaded translator" << locale;
qApp->installTranslator(translator);
}
}
void MainWindow::loadLanguage(const QString& rLanguage)
{
if(m_currLang != rLanguage) {
m_currLang = rLanguage;
QLocale locale = QLocale(m_currLang);
QLocale::setDefault(locale);
QString languageName = QLocale::languageToString(locale.language());
switchTranslator(translator, "gui_", locale);
switchTranslator(qtTranslator, "qt_", locale);
ui->statusBar->showMessage(tr("Current Language changed to %1").arg(languageName),3000);
}
}
void MainWindow::changeEvent(QEvent* event)
{
if(0 != event) {
switch(event->type()) {
// this event is send if a translator is loaded
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
if (event) {
switch (event->type()) {
case QEvent::LanguageChange:
// this event is send if a translator is loaded and installed to the Application
ui->retranslateUi(this);
break;
// this event is send, if the system, language changes
case QEvent::LocaleChange:
{
QString locale = QLocale::system().name();
locale.truncate(locale.lastIndexOf('_'));
loadLanguage(locale);
}
break;
case QEvent::LocaleChange:
// this event is send by QWidget::setLocale
translator->setLocale(QLocale::system());
break;
// Ignore other events
default:
break;
}
}
QMainWindow::changeEvent(event);
default:
// Ignore other events
break;
}
}
QMainWindow::changeEvent(event);
}
MainWindow::~MainWindow()

View File

@ -13,20 +13,19 @@
#include <QProgressBar>
#include <QSettings>
#include <QStringListModel>
#include <QTranslator>
#ifdef Q_OS_WIN
#include <QWinTaskbarButton>
#include <QWinTaskbarProgress>
#endif
//#include "colorstxtassistant.h"
#include "colorstxtwizard.h"
#include "configdialog.h"
#include "drawmapfigure.h"
#include "drawmapfiguretablemodel.h"
#include "figuredelegate.h"
#include "minetestmapperexe.h"
#include "translator.h"
namespace Ui {
class MainWindow;
@ -37,7 +36,7 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
explicit MainWindow(bool portable, const QString &translationsPath, QTranslator *translator, QTranslator *qtTranslator, QWidget *parent = 0);
explicit MainWindow(bool portable, Translator *translator, QWidget *parent = 0);
~MainWindow();
enum class GeometryGranularity {
@ -128,8 +127,6 @@ private slots:
void on_figureSelect_currentIndexChanged(int index);
void switchTranslator(QTranslator *translator, const QString &prefix, const QLocale &locale);
void on_actionOpen_Terminal_triggered();
private:
@ -146,20 +143,13 @@ private:
void finishUiInitialisation(void);
// loads a language by the given language shortcur (e.g. de, en)
void loadLanguage(const QString &rLanguage);
// creates the language menu dynamically from the content of m_langPath
void createLanguageMenu(void);
QTranslator *translator; // contains the translations for this application
QTranslator *qtTranslator; // contains the translations for qt
QString m_currLang; // contains the currently loaded language
QString translationsPath; // Path of language files. This is always fixed to /languages.
Translator *translator; // contains the translations for this application
QString currentProfile; //contains the name of current loaded profile
QString pathAppData; // Path where the settings should be stored.
QString pathProfiles; // path where the profiles should be stored.
//QSettings profile;
QSettings *settings;
QSettings *profile;
QString getColorsTxtFilePath(QDir *appDir, QDir *worldDir);

View File

@ -1290,7 +1290,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2373"/>
<location filename="../mainwindow.cpp" line="1040"/>
<location filename="../mainwindow.cpp" line="999"/>
<source>Cancel</source>
<translation>Abbrechen</translation>
</message>
@ -1323,7 +1323,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2649"/>
<location filename="../mainwindow.cpp" line="882"/>
<location filename="../mainwindow.cpp" line="841"/>
<source>About MinetestMapper</source>
<translation>Über MinetestMapper</translation>
</message>
@ -1367,7 +1367,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2786"/>
<location filename="../mainwindow.cpp" line="904"/>
<location filename="../mainwindow.cpp" line="863"/>
<source>New Profile</source>
<translation>Neues Profil</translation>
</message>
@ -1377,7 +1377,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2794"/>
<location filename="../mainwindow.cpp" line="462"/>
<location filename="../mainwindow.cpp" line="421"/>
<source>Expert Mode</source>
<translation>Expertenmodus</translation>
</message>
@ -1392,18 +1392,17 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
<translation>Im Expertenmodus werden die Parameter angezeigt, die du verändern kannst.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="231"/>
<source>Current Language changed to %1</source>
<translation>Sprache wurde auf %1 geändert</translation>
<translation type="vanished">Sprache wurde auf %1 geändert</translation>
</message>
<message>
<location filename="../mainwindow.ui" line="2745"/>
<location filename="../mainwindow.cpp" line="868"/>
<location filename="../mainwindow.cpp" line="827"/>
<source>About MinetestMapper GUI</source>
<translation>Über MinetestMapperGUI</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="279"/>
<location filename="../mainwindow.cpp" line="238"/>
<source>Minetestmapper not found</source>
<translation>Minetestmapper nicht gefunden</translation>
</message>
@ -1428,7 +1427,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
<translation type="vanished">Das Bild existiert bereits</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="309"/>
<location filename="../mainwindow.cpp" line="268"/>
<source>The File &lt;i&gt;%1&lt;/i&gt; does already exist. &lt;br&gt;&lt;br&gt;Do you want to overwrite?</source>
<translation>Die Datei &lt;i&gt;%1&lt;/i&gt; existiert bereits. &lt;br&gt;&lt;br&gt;Soll die Datei Überschrieben werden?</translation>
</message>
@ -1437,58 +1436,58 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
<translation type="vanished">Der Ordner existiert nicht</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="318"/>
<location filename="../mainwindow.cpp" line="277"/>
<source>The directory &lt;i&gt;%1&lt;/i&gt; does not exist. &lt;br&gt;&lt;br&gt;Should it be created?</source>
<translation>Der Ordner &lt;i&gt;%1&lt;/i&gt; existiert nicht. &lt;br&gt;&lt;br&gt;Möchten sie den Ordner erstellen?</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="463"/>
<location filename="../mainwindow.cpp" line="422"/>
<source>MinetestMapper will be executed using this arguments.
The arguments can be removed, modified, or new arguments can be added.</source>
<translation>MinetestMapper wird mit den folgenden Parametern ausgeführt.
Die einzelnen Parameter können entfernt, verändert, oder neue hinzugefügt werden.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="522"/>
<location filename="../mainwindow.cpp" line="481"/>
<source>Finisched :)</source>
<translation>Fertig :-)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="530"/>
<location filename="../mainwindow.cpp" line="489"/>
<source>minetestmapper terminated</source>
<translation>minetestmapper abgebrochen</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="273"/>
<location filename="../mainwindow.cpp" line="232"/>
<source>ERROR: No minetestmapper executable could not be found.
Please configure one. </source>
<translation>FEHLER: Kein Minetestmapper programm gefunden.
Bitte Konfiguriere eins.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="276"/>
<location filename="../mainwindow.cpp" line="235"/>
<source>ERROR: The Minetetmapper Application (%1) does not look like a Minetetestmapper
Please configure a correct MinetestMapper Application. </source>
<translation>FEHLER: Das Minetestmapper Programm (%1) ist möglicherweise kein Minetestmapper Programm.
Bitte Wählen sie eine Korrekte Minetestmapper Anwendung aus.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="281"/>
<location filename="../mainwindow.cpp" line="240"/>
<source>(Edit-&gt;Preferences)</source>
<translation>(Bearbeiten-&gt;Einstellungen)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="283"/>
<location filename="../mainwindow.cpp" line="242"/>
<source>Do you want to open Preferences now?</source>
<translation>Sollen die Einstellungen jetzt geöffnet werden?</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="295"/>
<location filename="../mainwindow.cpp" line="254"/>
<source>No input world selected</source>
<translation>Keine Welt ausgewählt</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="296"/>
<location filename="../mainwindow.cpp" line="255"/>
<source>ERROR: No MinetestWorld selected.
please select a world</source>
@ -1497,12 +1496,12 @@ please select a world</source>
Bitte wähle eine aus</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="302"/>
<location filename="../mainwindow.cpp" line="261"/>
<source>No output image selected</source>
<translation>Kein Ausgansbild ausgewählt</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="303"/>
<location filename="../mainwindow.cpp" line="262"/>
<source>ERROR: No output image selected.
Please select a output image</source>
@ -1511,28 +1510,28 @@ Please select a output image</source>
Bitte ein Ausgabebild wählen</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="308"/>
<location filename="../mainwindow.cpp" line="267"/>
<source>The image file does already exist</source>
<translation>Die Datei existiert bereits</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="317"/>
<location filename="../mainwindow.cpp" line="276"/>
<source>The directory does not exist</source>
<translation>Der Ordner existiert nicht</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="533"/>
<location filename="../mainwindow.cpp" line="550"/>
<location filename="../mainwindow.cpp" line="492"/>
<location filename="../mainwindow.cpp" line="509"/>
<source>Minetest Mapper failed</source>
<translation>Minetestmapper hat ein Fehler festgestellt</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="534"/>
<location filename="../mainwindow.cpp" line="493"/>
<source>&lt;h1&gt;ERROR&lt;/h1&gt; &lt;h2&gt;minetestmapper failed&lt;/h2&gt;Exit code: &lt;i&gt;%1&lt;/i&gt; &lt;br&gt;Status of MinetestMapper: &lt;pre&gt;%2&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Please fix the error and try again </source>
<translation>&lt;h1&gt;Fehler&lt;/h1&gt; &lt;h2&gt;kartenerstellung fehlgeschlagen&lt;/h2&gt;Exit code: &lt;i&gt;%1&lt;/i&gt; &lt;br&gt;Ausgabe des Minetstmapper: &lt;pre&gt;%2&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Bitte den Fehler beheben und erneut versuchen </translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="551"/>
<location filename="../mainwindow.cpp" line="510"/>
<source>&lt;h1&gt;ERROR&lt;/h1&gt; &lt;h2&gt;minetestmapper failed&lt;/h2&gt;Error code: &lt;i&gt;%1&lt;/i&gt; &lt;br&gt;Error Message: &lt;pre&gt;%2&lt;/pre&gt;&lt;br&gt;</source>
<translation>&lt;h1&gt;FEHLER&lt;/h1&gt; &lt;h2&gt;minetestmapper ist abgestürzt&lt;/h2&gt;Fehlercode: &lt;i&gt;%1&lt;/i&gt; &lt;br&gt;Fehlernachricht: &lt;pre&gt;%2&lt;/pre&gt;&lt;br&gt;</translation>
</message>
@ -1545,92 +1544,92 @@ Bitte ein Ausgabebild wählen</translation>
<translation type="vanished">Konnte die Einstellungen nicht migrieren</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="605"/>
<location filename="../mainwindow.cpp" line="564"/>
<source>Can not save settings</source>
<translation>Kann die Einstellungen nicht speichern</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="606"/>
<location filename="../mainwindow.cpp" line="565"/>
<source>Minetest Mapper GUI could not save the settings to %1.
Please make shure Minetest Mapper Gui can access to the file/directory</source>
<translation>Minetest Mapper GUI konnte die Einstellungen nicht nach %1 speichern.
Bitte stelle sicher, dass Minetest Mapper GUI auf die Datei/ den Ordner zugreifen darf.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="630"/>
<location filename="../mainwindow.cpp" line="589"/>
<source>Can not save profile</source>
<translation>Konnte das Profil nicht speichern</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="631"/>
<location filename="../mainwindow.cpp" line="590"/>
<source>Minetest Mapper GUI could not save the current Profile &apos;%1&apos; to %2.
Please make shure Minetest Mapper Gui can access to the file/directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="826"/>
<location filename="../mainwindow.cpp" line="785"/>
<source>Open Minetest World</source>
<translation>Minetest Welt-Ordner öffnen</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="836"/>
<location filename="../mainwindow.cpp" line="795"/>
<source>Save generated map to...</source>
<translation>Karte speichern nach...</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="836"/>
<location filename="../mainwindow.cpp" line="795"/>
<source>png image (*.png)</source>
<translation>png Grafik (*.png)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="843"/>
<location filename="../mainwindow.cpp" line="802"/>
<source>Open HeightmapNodes File</source>
<translation>Öffne HeightmapNodes Datei</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="845"/>
<location filename="../mainwindow.cpp" line="853"/>
<location filename="../mainwindow.cpp" line="861"/>
<location filename="../mainwindow.cpp" line="804"/>
<location filename="../mainwindow.cpp" line="812"/>
<location filename="../mainwindow.cpp" line="820"/>
<source>TXT File (*.txt)</source>
<translation>TXT Datei (*.txt)</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="851"/>
<location filename="../mainwindow.cpp" line="810"/>
<source>Open HeightmapColors File</source>
<translation>Öffne Höhenkarte Farbdefinitionsdatei</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="859"/>
<location filename="../mainwindow.cpp" line="818"/>
<source>Open colors.txt File</source>
<translation>Öffne colors.txt Datei</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="869"/>
<location filename="../mainwindow.cpp" line="828"/>
<source>&lt;h1&gt;About MinetestMapperGUI&lt;/h1&gt;The &lt;b&gt;MinetestMapper Gui&lt;/b&gt; is written by addi.&lt;br /&gt;It is licensed under a &lt;a href=&quot;http://creativecommons.org/licenses/by/3.0/&quot;&gt;Creative Commons Attribution 3.0 Unported License&lt;/a&gt;.&lt;br&gt;The current version is %1. &lt;br&gt;The sourcecode is aviable on &lt;a href=&apos;https://bitbucket.org/adrido/minetestmappergui/&apos;&gt;Bitbucket&lt;/a&gt;.&lt;br&gt;You may also want to read the &lt;a href=&apos;https://forum.minetest.net/viewtopic.php?f=14&amp;t=12139&apos;&gt;Minetest forum thread&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;Thanks to:&lt;/b&gt;&lt;br&gt;McKrustenkaese for his great icon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="883"/>
<location filename="../mainwindow.cpp" line="842"/>
<source>&lt;h1&gt;About MinetestMapper&lt;/h1&gt;The &lt;b&gt;MinetestMapper&lt;/b&gt; is written by:&lt;br&gt;Miroslav Bendík &lt;miroslav.bendik@gmail.com&gt;&lt;br&gt;ShadowNinja &lt;shadowninja@minetest.net&gt;&lt;br&gt;sfan5 &lt;sfan5@live.de&gt;&lt;br&gt;Rogier &lt;rogier777@gmail.com&gt;&lt;br&gt;&lt;br&gt;&lt;u&gt;Version:&lt;/u&gt; %1 (%2)&lt;br&gt;&lt;u&gt;License:&lt;/u&gt; LGPLv2.1+ and BSD 2-clause.&lt;br&gt;&lt;u&gt;Source Code:&lt;/u&gt; &lt;a href=&apos;https://github.com/Rogier-5/minetest-mapper-cpp&apos;&gt;Github&lt;/a&gt;&lt;br&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="964"/>
<location filename="../mainwindow.cpp" line="923"/>
<source>map center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="969"/>
<location filename="../mainwindow.cpp" line="928"/>
<source>map origin (top left)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1019"/>
<location filename="../mainwindow.cpp" line="978"/>
<source>Create a colors.txt</source>
<translation>Erstelle eine colors.txt Datei</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1020"/>
<location filename="../mainwindow.cpp" line="979"/>
<source>There is a nodes.txt but no colors.txt in the world directory
Do you want to generate one?
If you select &apos;No&apos; the default colors.txt will be used.</source>
@ -1639,29 +1638,29 @@ Möchtest du eine erstellen?
Wenn du auf &apos;Nein&apos; clickst, wird eine standard colors.txt Datei verwendet.</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1037"/>
<location filename="../mainwindow.cpp" line="996"/>
<source>No colors.txt file</source>
<translation>Keine colors.txt Datei</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1038"/>
<location filename="../mainwindow.cpp" line="997"/>
<source>ERROR: Still no colors.txt file found inside world directory.
Do you want to cancel or proceed with default colors.txt file?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1041"/>
<location filename="../mainwindow.cpp" line="1000"/>
<source>Proceed with default</source>
<translation>Mit standard Datei fortfahren</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1113"/>
<location filename="../mainwindow.cpp" line="1072"/>
<source>Could not open Terminal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1114"/>
<location filename="../mainwindow.cpp" line="1073"/>
<source>Error: Could not open scriptfile (%1) for Terminal</source>
<translation type="unfinished"></translation>
</message>
@ -1696,12 +1695,12 @@ Bitte erneut eine gültige minetestmapper Anwendung auswählen. (Bearbeiten-&gt;
Möchten Sie die Einstellungen jetzt öffnen? </translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="897"/>
<location filename="../mainwindow.cpp" line="856"/>
<source>preview: %1</source>
<translation>Vorschau: %1</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="905"/>
<location filename="../mainwindow.cpp" line="864"/>
<source>Name of the new Profile:</source>
<translation>Name des Neuen Profils:</translation>
</message>

View File

@ -978,7 +978,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2373"/>
<location filename="../mainwindow.cpp" line="1040"/>
<location filename="../mainwindow.cpp" line="999"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
@ -1036,7 +1036,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2649"/>
<location filename="../mainwindow.cpp" line="882"/>
<location filename="../mainwindow.cpp" line="841"/>
<source>About MinetestMapper</source>
<translation type="unfinished"></translation>
</message>
@ -1072,7 +1072,7 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2745"/>
<location filename="../mainwindow.cpp" line="868"/>
<location filename="../mainwindow.cpp" line="827"/>
<source>About MinetestMapper GUI</source>
<translation type="unfinished"></translation>
</message>
@ -1123,13 +1123,13 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
</message>
<message>
<location filename="../mainwindow.ui" line="2786"/>
<location filename="../mainwindow.cpp" line="904"/>
<location filename="../mainwindow.cpp" line="863"/>
<source>New Profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.ui" line="2794"/>
<location filename="../mainwindow.cpp" line="462"/>
<location filename="../mainwindow.cpp" line="421"/>
<source>Expert Mode</source>
<translation type="unfinished"></translation>
</message>
@ -1174,238 +1174,233 @@ Nodes higher than this level will not be drawn. This can be used to avoid floati
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="231"/>
<source>Current Language changed to %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="273"/>
<location filename="../mainwindow.cpp" line="232"/>
<source>ERROR: No minetestmapper executable could not be found.
Please configure one. </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="276"/>
<location filename="../mainwindow.cpp" line="235"/>
<source>ERROR: The Minetetmapper Application (%1) does not look like a Minetetestmapper
Please configure a correct MinetestMapper Application. </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="279"/>
<location filename="../mainwindow.cpp" line="238"/>
<source>Minetestmapper not found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="309"/>
<location filename="../mainwindow.cpp" line="268"/>
<source>The File &lt;i&gt;%1&lt;/i&gt; does already exist. &lt;br&gt;&lt;br&gt;Do you want to overwrite?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="318"/>
<location filename="../mainwindow.cpp" line="277"/>
<source>The directory &lt;i&gt;%1&lt;/i&gt; does not exist. &lt;br&gt;&lt;br&gt;Should it be created?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="463"/>
<location filename="../mainwindow.cpp" line="422"/>
<source>MinetestMapper will be executed using this arguments.
The arguments can be removed, modified, or new arguments can be added.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="522"/>
<location filename="../mainwindow.cpp" line="481"/>
<source>Finisched :)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="530"/>
<location filename="../mainwindow.cpp" line="489"/>
<source>minetestmapper terminated</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="281"/>
<location filename="../mainwindow.cpp" line="240"/>
<source>(Edit-&gt;Preferences)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="283"/>
<location filename="../mainwindow.cpp" line="242"/>
<source>Do you want to open Preferences now?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="295"/>
<location filename="../mainwindow.cpp" line="254"/>
<source>No input world selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="296"/>
<location filename="../mainwindow.cpp" line="255"/>
<source>ERROR: No MinetestWorld selected.
please select a world</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="302"/>
<location filename="../mainwindow.cpp" line="261"/>
<source>No output image selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="303"/>
<location filename="../mainwindow.cpp" line="262"/>
<source>ERROR: No output image selected.
Please select a output image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="308"/>
<location filename="../mainwindow.cpp" line="267"/>
<source>The image file does already exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="317"/>
<location filename="../mainwindow.cpp" line="276"/>
<source>The directory does not exist</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="533"/>
<location filename="../mainwindow.cpp" line="550"/>
<location filename="../mainwindow.cpp" line="492"/>
<location filename="../mainwindow.cpp" line="509"/>
<source>Minetest Mapper failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="534"/>
<location filename="../mainwindow.cpp" line="493"/>
<source>&lt;h1&gt;ERROR&lt;/h1&gt; &lt;h2&gt;minetestmapper failed&lt;/h2&gt;Exit code: &lt;i&gt;%1&lt;/i&gt; &lt;br&gt;Status of MinetestMapper: &lt;pre&gt;%2&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Please fix the error and try again </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="551"/>
<location filename="../mainwindow.cpp" line="510"/>
<source>&lt;h1&gt;ERROR&lt;/h1&gt; &lt;h2&gt;minetestmapper failed&lt;/h2&gt;Error code: &lt;i&gt;%1&lt;/i&gt; &lt;br&gt;Error Message: &lt;pre&gt;%2&lt;/pre&gt;&lt;br&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="605"/>
<location filename="../mainwindow.cpp" line="564"/>
<source>Can not save settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="606"/>
<location filename="../mainwindow.cpp" line="565"/>
<source>Minetest Mapper GUI could not save the settings to %1.
Please make shure Minetest Mapper Gui can access to the file/directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="630"/>
<location filename="../mainwindow.cpp" line="589"/>
<source>Can not save profile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="631"/>
<location filename="../mainwindow.cpp" line="590"/>
<source>Minetest Mapper GUI could not save the current Profile &apos;%1&apos; to %2.
Please make shure Minetest Mapper Gui can access to the file/directory</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="826"/>
<location filename="../mainwindow.cpp" line="785"/>
<source>Open Minetest World</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="836"/>
<location filename="../mainwindow.cpp" line="795"/>
<source>Save generated map to...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="836"/>
<location filename="../mainwindow.cpp" line="795"/>
<source>png image (*.png)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="843"/>
<location filename="../mainwindow.cpp" line="802"/>
<source>Open HeightmapNodes File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="845"/>
<location filename="../mainwindow.cpp" line="853"/>
<location filename="../mainwindow.cpp" line="861"/>
<location filename="../mainwindow.cpp" line="804"/>
<location filename="../mainwindow.cpp" line="812"/>
<location filename="../mainwindow.cpp" line="820"/>
<source>TXT File (*.txt)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="851"/>
<location filename="../mainwindow.cpp" line="810"/>
<source>Open HeightmapColors File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="859"/>
<location filename="../mainwindow.cpp" line="818"/>
<source>Open colors.txt File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="869"/>
<location filename="../mainwindow.cpp" line="828"/>
<source>&lt;h1&gt;About MinetestMapperGUI&lt;/h1&gt;The &lt;b&gt;MinetestMapper Gui&lt;/b&gt; is written by addi.&lt;br /&gt;It is licensed under a &lt;a href=&quot;http://creativecommons.org/licenses/by/3.0/&quot;&gt;Creative Commons Attribution 3.0 Unported License&lt;/a&gt;.&lt;br&gt;The current version is %1. &lt;br&gt;The sourcecode is aviable on &lt;a href=&apos;https://bitbucket.org/adrido/minetestmappergui/&apos;&gt;Bitbucket&lt;/a&gt;.&lt;br&gt;You may also want to read the &lt;a href=&apos;https://forum.minetest.net/viewtopic.php?f=14&amp;t=12139&apos;&gt;Minetest forum thread&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;b&gt;Thanks to:&lt;/b&gt;&lt;br&gt;McKrustenkaese for his great icon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="883"/>
<location filename="../mainwindow.cpp" line="842"/>
<source>&lt;h1&gt;About MinetestMapper&lt;/h1&gt;The &lt;b&gt;MinetestMapper&lt;/b&gt; is written by:&lt;br&gt;Miroslav Bendík &lt;miroslav.bendik@gmail.com&gt;&lt;br&gt;ShadowNinja &lt;shadowninja@minetest.net&gt;&lt;br&gt;sfan5 &lt;sfan5@live.de&gt;&lt;br&gt;Rogier &lt;rogier777@gmail.com&gt;&lt;br&gt;&lt;br&gt;&lt;u&gt;Version:&lt;/u&gt; %1 (%2)&lt;br&gt;&lt;u&gt;License:&lt;/u&gt; LGPLv2.1+ and BSD 2-clause.&lt;br&gt;&lt;u&gt;Source Code:&lt;/u&gt; &lt;a href=&apos;https://github.com/Rogier-5/minetest-mapper-cpp&apos;&gt;Github&lt;/a&gt;&lt;br&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="964"/>
<location filename="../mainwindow.cpp" line="923"/>
<source>map center</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="969"/>
<location filename="../mainwindow.cpp" line="928"/>
<source>map origin (top left)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1019"/>
<location filename="../mainwindow.cpp" line="978"/>
<source>Create a colors.txt</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1020"/>
<location filename="../mainwindow.cpp" line="979"/>
<source>There is a nodes.txt but no colors.txt in the world directory
Do you want to generate one?
If you select &apos;No&apos; the default colors.txt will be used.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1037"/>
<location filename="../mainwindow.cpp" line="996"/>
<source>No colors.txt file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1038"/>
<location filename="../mainwindow.cpp" line="997"/>
<source>ERROR: Still no colors.txt file found inside world directory.
Do you want to cancel or proceed with default colors.txt file?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1041"/>
<location filename="../mainwindow.cpp" line="1000"/>
<source>Proceed with default</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1113"/>
<location filename="../mainwindow.cpp" line="1072"/>
<source>Could not open Terminal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="1114"/>
<location filename="../mainwindow.cpp" line="1073"/>
<source>Error: Could not open scriptfile (%1) for Terminal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="897"/>
<location filename="../mainwindow.cpp" line="856"/>
<source>preview: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="905"/>
<location filename="../mainwindow.cpp" line="864"/>
<source>Name of the new Profile:</source>
<translation type="unfinished"></translation>
</message>

50
translator.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "translator.h"
#include <QApplication>
#include <QLibraryInfo>
#include <QDebug>
#include <QDir>
Translator::Translator(const QLocale &locale)
{
load(locale);
}
void Translator::load(const QLocale &locale)
{
qDebug() << "Loading Locale:" << locale;
if (qtTranslator.load(locale, "qt", "_", systemTranslationPath)) {
qApp->installTranslator(&qtTranslator);
qDebug() << "Qt Translator installed from system path" << systemTranslationPath;
}
else {
qtTranslator.load(locale, "qt", "_", translationsPath);
qApp->installTranslator(&qtTranslator);
qDebug() << "Qt Translator installed from standard path" << translationsPath;
}
if (appTranslator.load(locale, "gui", "_", translationsPath))
qApp->installTranslator(&appTranslator);
}
QStringList Translator::getTranslations() const
{
QDir dir(translationsPath);
QStringList fileNames = dir.entryList(QStringList("qt_*.qm"));
for (QString &s : fileNames) {
s.truncate(s.lastIndexOf('.')); // "qt_de"
s.remove(0, s.indexOf('_') + 1); // "de"
}
return fileNames;
}
bool Translator::setLocale(const QLocale & newLocale)
{
if (currentLocale == newLocale)
return false;
QLocale::setDefault(newLocale);
currentLocale = newLocale;
load(newLocale);
return true;
}

30
translator.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef TRANSLATOR_H
#define TRANSLATOR_H
#include <QLibraryInfo>
#include <QLocale>
#include <QString>
#include <QStringList>
#include <QTranslator>
class Translator
{
public:
explicit Translator(const QLocale &locale = QLocale::system());
const QString translationsPath = "./translations/";
const QString systemTranslationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
QStringList getTranslations() const;
QLocale getCurrentLocale() const { return currentLocale; }
bool setLocale(const QLocale &newLocale);
private:
void load(const QLocale &locale);
QLocale currentLocale;
QTranslator qtTranslator;
QTranslator appTranslator;
};
#endif // TRANSLATOR_H