Skip to content

Commit

Permalink
I18N was improved. Translation GUI to Russian was made.
Browse files Browse the repository at this point in the history
  • Loading branch information
VanDerSam committed Jul 15, 2014
1 parent 13464f4 commit 87bda98
Show file tree
Hide file tree
Showing 10 changed files with 2,507 additions and 291 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ src/debug
src/release
src/gen_version.h

# ignore compiled translation files
src/translations/*.qm

# no one needs the txt file
src/grammar/sqlite3TokenTypes.txt

Expand Down
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,26 @@ set(SQLB_RESOURCES
src/icons/icons.qrc
)

# Translation files
set(SQLB_TSS
${CMAKE_SOURCE_DIR}/src/translations/sqlb_de.ts
${CMAKE_SOURCE_DIR}/src/translations/sqlb_ru.ts
)

if(USE_QT5)
qt5_wrap_ui(SQLB_FORM_HDR ${SQLB_FORMS})
qt5_add_resources(SQLB_RESOURCES_RCC ${SQLB_RESOURCES})
else()
QT4_WRAP_CPP(SQLB_MOC ${SQLB_MOC_HDR})
QT4_WRAP_UI(SQLB_FORM_HDR ${SQLB_FORMS})
QT4_ADD_RESOURCES(SQLB_RESOURCES_RCC ${SQLB_RESOURCES})
if(SQLB_TSS)
# add translations
foreach(SQLB_TS ${SQLB_TSS})
SET_SOURCE_FILES_PROPERTIES(${SQLB_TS} PROPERTIES OUTPUT_LOCATION "${CMAKE_BINARY_DIR}/translations")
endforeach(SQLB_TS ${SQLB_TSS})
QT4_ADD_TRANSLATION(SQLB_QMS ${SQLB_TSS})
endif(SQLB_TSS)
endif()

# get git version hash
Expand Down Expand Up @@ -168,7 +181,8 @@ add_executable(${PROJECT_NAME}
${SQLB_SRC}
${SQLB_FORM_HDR}
${SQLB_MOC}
${SQLB_RESOURCES_RCC})
${SQLB_RESOURCES_RCC}
${SQLB_QMS})

if(USE_QT5)
qt5_use_modules(${PROJECT_NAME} Gui Widgets Network Test PrintSupport)
Expand Down
27 changes: 22 additions & 5 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,29 @@ Application::Application(int& argc, char** argv) :
#endif

// Load translations
m_translatorQt = new QTranslator(this);
m_translatorQt->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
installTranslator(m_translatorQt);
bool ok;
QString name = QLocale::system().name();

// First of all try to load the application translation file.
m_translatorApp = new QTranslator(this);
m_translatorApp->load("tr_" + QLocale::system().name(), "translations");
installTranslator(m_translatorApp);
ok = m_translatorApp->load("sqlb_" + name, "translations");
if (ok == true) {
installTranslator(m_translatorApp);

// The application translation file has been found and loaded.
// And now try to load a Qt translation file.
// Search path:
// 1) standard Qt translations directory;
// 2) the application translations directory.
m_translatorQt = new QTranslator(this);

ok = m_translatorQt->load("qt_" + name,
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
if (ok == false)
ok = m_translatorQt->load("qt_" + name, "translations");
if (ok == true)
installTranslator(m_translatorQt);
}

// Parse command line
QString fileToOpen;
Expand Down
8 changes: 4 additions & 4 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>637</width>
<height>501</height>
<width>281</width>
<height>444</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
Expand Down Expand Up @@ -1033,7 +1033,7 @@
<item>
<widget class="QPushButton" name="butSavePlot">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Save current plot...&lt;/p&gt;&lt;p&gt;File format choosen by extension (png, jpg, pdf, bmp)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Save current plot...&lt;/p&gt;&lt;p&gt;File format chosen by extension (png, jpg, pdf, bmp)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>Save current plot...</string>
Expand Down Expand Up @@ -1256,7 +1256,7 @@
<string>Delete Table...</string>
</property>
<property name="toolTip">
<string>Delete Object</string>
<string>Delete Table</string>
</property>
<property name="whatsThis">
<string>Open the Delete Table wizard, where you can select a database table to be dropped.</string>
Expand Down
40 changes: 40 additions & 0 deletions src/i18n.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file is taken from the project https://gitorious.org/qop/qop/.
# For autocompiling qm-files.

#rules to generate ts
isEmpty(QMAKE_LUPDATE) {
win32: QMAKE_LUPDATE = $$[QT_INSTALL_BINS]/lupdate.exe
unix {
QMAKE_LUPDATE = $$[QT_INSTALL_BINS]/lupdate
!exists($$QMAKE_LUPDATE) { QMAKE_LUPDATE = lupdate-qt4 }
} else {
!exists($$QMAKE_LUPDATE) { QMAKE_LUPDATE = lupdate }
}
}
#limitation: only on ts can be generated
updatets.name = Creating or updating ts-files...
updatets.input = _PRO_FILE_
updatets.output = $$TRANSLATIONS
updatets.commands = $$QMAKE_LUPDATE ${QMAKE_FILE_IN}
updatets.CONFIG += no_link no_clean
QMAKE_EXTRA_COMPILERS += updatets

#rules for ts->qm
isEmpty(QMAKE_LRELEASE) {
#a qm generated by lrelease-qt3 can be used for qt2, qt3, qt4!
win32: QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
unix {
QMAKE_LRELEASE = lrelease-qt3
!exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease }
!exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease }
!exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease-qt4 }
} else {
!exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease }
}
}
updatets.name = Compiling qm-files...
updateqm.input = TRANSLATIONS
updateqm.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
updateqm.CONFIG += no_link no_clean target_predeps
QMAKE_EXTRA_COMPILERS += updateqm
6 changes: 5 additions & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ FORMS += \
VacuumDialog.ui

TRANSLATIONS += \
translations/tr_de.ts
translations/sqlb_de.ts \
translations/sqlb_ru.ts

LIBPATH_QHEXEDIT=$$PWD/../libs/qhexedit
LIBPATH_ANTLR=$$PWD/../libs/antlr-2.7.7
Expand Down Expand Up @@ -117,3 +118,6 @@ UI_DIR = .ui
INCLUDEPATH += $$PWD/../libs/antlr-2.7.7 $$PWD/../libs/qhexedit $$PWD/../libs/qcustomplot-source $$PWD/..
LIBS += -L$$LIBPATH_QHEXEDIT -L$$LIBPATH_ANTLR -L$$LIBPATH_QCUSTOMPLOT -lantlr -lqhexedit -lqcustomplot -lsqlite3
DEPENDPATH += $$PWD/../libs/antlr-2.7.7 $$PWD/../libs/qhexedit $$PWD/../libs/qcustomplot-source

# Rules for creating/updating {ts|qm}-files
include(i18n.pri)
1 change: 1 addition & 0 deletions src/translations/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TS files for the application should be all named according to a convention such as <short_appname>_<locale>, e.g. sqlb_de, sqlb_ru etc.
Loading

0 comments on commit 87bda98

Please sign in to comment.