Skip to content

Commit

Permalink
Merge pull request #38 from lgolouz/lgolouz_zxtr-37
Browse files Browse the repository at this point in the history
Fixed [ZXTR-37] Implement support of localization
  • Loading branch information
lgolouz authored Nov 1, 2021
2 parents 7487778 + cb8adc0 commit 4382746
Show file tree
Hide file tree
Showing 25 changed files with 1,208 additions and 424 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Generated sources
generated/

# C++ objects and libs
*.slo
*.lo
Expand Down
57 changes: 53 additions & 4 deletions ZXTapeReviver.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,76 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++14

#Dynamically generate translation names and country codes based on AVAILABLE_TRANSLATIONS variable
AVAILABLE_TRANSLATIONS = English:en_US Russian:ru_RU

TRANSLATION_FILENAME = zxtapereviver_
TRANSLATIONS_PATH = ./qml/translations/

for (T, AVAILABLE_TRANSLATIONS) {
S = $$split(T, ":")
TRANSLATION_LANGUAGE = $$take_first(S)
COUNTRY_CODE = $$take_last(S)

TRANSLATION_ID = ID_$${TRANSLATION_LANGUAGE}_LANGUAGE
TRANSLATION_ID_UPPER = $$upper($${TRANSLATION_ID})
TRANSLATION_ID_LOWER = $$lower($${TRANSLATION_ID})
TRANSLATION_ID_HEADER = "extern const char* $${TRANSLATION_ID_UPPER};"
TRANSLATION_ID_CODE = "const char* $${TRANSLATION_ID_UPPER}=QT_TRID_NOOP(\"$${TRANSLATION_ID_LOWER}\");"

isEmpty(DEFINED_TRANSLATIONS) {
COUNTRY_CODES = $${COUNTRY_CODE}
DEFINED_TRANSLATIONS = $${T}
}
else {
COUNTRY_CODES = $${COUNTRY_CODES},$${COUNTRY_CODE}
DEFINED_TRANSLATIONS = $${DEFINED_TRANSLATIONS};$${T}
}
TRANSLATION_IDS_HEADER = $${TRANSLATION_IDS_HEADER} $${TRANSLATION_ID_HEADER}
TRANSLATION_IDS_CODE = $${TRANSLATION_IDS_CODE} $${TRANSLATION_ID_CODE}

system($$[QT_INSTALL_BINS]/lrelease -idbased $${TRANSLATIONS_PATH}/$${TRANSLATION_FILENAME}$${COUNTRY_CODE}.xlf -qm $${TRANSLATIONS_PATH}/$${TRANSLATION_FILENAME}$${COUNTRY_CODE}.qm)
}
DEFINES += AVAILABLE_TRANSLATIONS=\\\"$${DEFINED_TRANSLATIONS}\\\" \
COUNTRY_CODES=$${COUNTRY_CODES}

TRANSLATIONS_GENERATED_FILENAME = $${PWD}/generated/translations_generated
TRANSLATIONS_GENERATED_FILENAME_H = $${TRANSLATIONS_GENERATED_FILENAME}.h
TRANSLATIONS_GENERATED_FILENAME_CPP = $${TRANSLATIONS_GENERATED_FILENAME}.cpp

write_file($${TRANSLATIONS_GENERATED_FILENAME_H}, TRANSLATION_IDS_HEADER)
write_file($${TRANSLATIONS_GENERATED_FILENAME_CPP}, TRANSLATION_IDS_CODE)


DEFINES += TRANSLATION_IDS_HEADER="\\\"$${TRANSLATIONS_GENERATED_FILENAME_H}\\\"" \
TRANSLATION_IDS_CODE="\\\"$${TRANSLATIONS_GENERATED_FILENAME_CPP}\\\""


SOURCES += \
sources/controls/waveformcustomization.cpp \
sources/main.cpp \
sources/models/fileworkermodel.cpp \
sources/controls/waveformcontrol.cpp \
sources/core/waveformparser.cpp \
sources/core/wavreader.cpp \
sources/models/parsersettingsmodel.cpp \
sources/models/suspiciouspointsmodel.cpp \
sources/util/enummetainfo.cpp
sources/translations/translationmanager.cpp \
sources/translations/translations.cpp \
sources/util/enummetainfo.cpp \
sources/configuration/configurationmanager.cpp

HEADERS += \
sources/controls/waveformcustomization.h \
sources/defines.h \
sources/models/fileworkermodel.h \
sources/controls/waveformcontrol.h \
sources/core/waveformparser.h \
sources/core/wavreader.h \
sources/models/parsersettingsmodel.h \
sources/models/suspiciouspointsmodel.h \
sources/util/enummetainfo.h
sources/translations/translationmanager.h \
sources/translations/translations.h \
sources/util/enummetainfo.h \
sources/configuration/configurationmanager.h

RESOURCES += qml/qml.qrc

Expand Down
19 changes: 14 additions & 5 deletions qml/About.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15

import "."

Dialog {
id: aboutDialog

visible: false
title: "About..."
title: Translations.id_about_window_header
standardButtons: StandardButton.Ok
modality: Qt.WindowModal
width: 300
Expand All @@ -39,22 +41,29 @@ Dialog {
Text {
id: emailText
anchors.top: skipText.bottom
text: 'E-mail: <a href="mailto:[email protected]">[email protected]</a>'
text: Translations.id_email_link
onLinkActivated: Qt.openUrlExternally(link)
}
Text {
id: youtubeText
anchors.top: emailText.bottom
text: 'YouTube channel: <a href="https://www.youtube.com/channel/UCz_ktTqWVekT0P4zVW8Xgcg">Советы компьютерного энтузиаста</a> - <a href="https://www.youtube.com/channel/UCz_ktTqWVekT0P4zVW8Xgcg">Computer Enthusiast Tips</a>'
text: Translations.id_youtube_channel_link
onLinkActivated: Qt.openUrlExternally(link)
}
Text {
id: skip2Text
id: donationText
anchors.top: youtubeText.bottom
text: Translations.id_donations_link
onLinkActivated: Qt.openUrlExternally(link)
}

Text {
id: skip2Text
anchors.top: donationText.bottom
text: ""
}
Text {
anchors.top: skip2Text.bottom
text: "Please click the highlighted links to open"
text: Translations.id_please_click_to_open_link
}
}
4 changes: 2 additions & 2 deletions qml/Frequency.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Dialog {
property var frequency: 0

visible: false
title: "Measured frequency"
title: Translations.id_measured_frequency_window_header
standardButtons: StandardButton.Ok
modality: Qt.WindowModal
width: 200
height: 120

Text {
id: textWithField
text: "Measured frequency:"
text: Translations.id_measured_frequency
}

TextField {
Expand Down
8 changes: 4 additions & 4 deletions qml/GoToAddress.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Dialog {
signal gotoAddress(int adr);

visible: false
title: "Go to address..."
title: Translations.id_goto_address_window_header
standardButtons: StandardButton.Ok | StandardButton.Cancel
modality: Qt.WindowModal
width: 200
width: 250
height: 120

Text {
id: textWithField
text: "Please enter address:"
text: Translations.id_please_enter_address
}

TextField {
Expand All @@ -44,7 +44,7 @@ Dialog {
anchors.top: textField.bottom
anchors.topMargin: 3
checked: true
text: "Hexadecimal"
text: Translations.id_hexadecimal
}

Text {
Expand Down
41 changes: 22 additions & 19 deletions qml/ParserSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,28 @@ import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15

import com.models.zxtapereviver 1.0
import "."

Dialog {
id: parserSettingsDialog

visible: false
title: "Parser settings"
title: Translations.id_parser_settings_window_header
standardButtons: StandardButton.Ok | StandardButton.RestoreDefaults
modality: Qt.WindowModal
width: grid.width * 1.02

Grid {
id: grid
columns: 4
anchors.horizontalCenter: parent.horizontalCenter

GroupBox {
title: "Pilot-tone settings:"
title: Translations.id_pilot_tone_settings
ColumnLayout {
Layout.fillHeight: true
Text {
text: "Pilot half frequency:"
text: Translations.id_pilot_half_frequency
}

TextField {
Expand All @@ -46,7 +49,7 @@ Dialog {
}

Text {
text: "Pilot frequency:"
text: Translations.id_pilot_frequency
}

TextField {
Expand All @@ -57,7 +60,7 @@ Dialog {
}

Text {
text: "Pilot delta:"
text: Translations.id_pilot_delta
}

TextField {
Expand All @@ -70,10 +73,10 @@ Dialog {
}

GroupBox {
title: "Synchro signal settigns:"
title: Translations.id_synchro_signal_settings
ColumnLayout {
Text {
text: "Synchro first half frequency:"
text: Translations.id_synchro_first_half_frequency
}

TextField {
Expand All @@ -84,7 +87,7 @@ Dialog {
}

Text {
text: "Synchro second half frequency:"
text: Translations.id_synchro_second_half_frequency
}

TextField {
Expand All @@ -95,7 +98,7 @@ Dialog {
}

Text {
text: "Synchro frequency:"
text: Translations.id_synchro_frequency
}

TextField {
Expand All @@ -106,7 +109,7 @@ Dialog {
}

Text {
text: "Synchro delta:"
text: Translations.id_synchro_delta
}

TextField {
Expand All @@ -119,10 +122,10 @@ Dialog {
}

GroupBox {
title: "Zero digit settings:"
title: Translations.id_zero_digit_settings
ColumnLayout {
Text {
text: "Zero half frequency:"
text: Translations.id_zero_half_frequency
}

TextField {
Expand All @@ -133,7 +136,7 @@ Dialog {
}

Text {
text: "Zero frequency:"
text: Translations.id_zero_frequency
}

TextField {
Expand All @@ -144,7 +147,7 @@ Dialog {
}

Text {
text: "Zero delta:"
text: Translations.id_zero_delta
}

TextField {
Expand All @@ -157,10 +160,10 @@ Dialog {
}

GroupBox {
title: "One digit settings:"
title: Translations.id_one_digit_settings
ColumnLayout {
Text {
text: "One half frequency:"
text: Translations.id_one_half_frequency
}

TextField {
Expand All @@ -171,7 +174,7 @@ Dialog {
}

Text {
text: "One frequency:"
text: Translations.id_one_frequency
}

TextField {
Expand All @@ -182,7 +185,7 @@ Dialog {
}

Text {
text: "One delta:"
text: Translations.id_one_delta
}

TextField {
Expand All @@ -198,7 +201,7 @@ Dialog {
anchors.top: grid.bottom
anchors.topMargin: 5

text: "Check for abnormal sine when parsing"
text: Translations.id_check_for_abnormal_sine_when_parsing
checked: ParserSettingsModel.checkForAbnormalSine
onCheckedChanged: {
ParserSettingsModel.checkForAbnormalSine = checked;
Expand Down
Loading

0 comments on commit 4382746

Please sign in to comment.