From 901109409b51c1e64c9a4c733c3e919f884fc81d Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 6 Mar 2019 10:32:21 -0800 Subject: [PATCH] adding i18n support --- i18n/translation_de.qm | Bin 0 -> 23 bytes i18n/translation_de.ts | 232 ++++++++++++++++++++++++++++++++ i18n/translation_en.qm | Bin 0 -> 23 bytes i18n/translation_en.ts | 191 ++++++++++++++++++++++++++ main.go | 4 + qml.qrc | 35 +++++ qml/panes/AddGroupPane.qml | 10 +- qml/panes/GroupSettingsPane.qml | 18 +-- qml/panes/OverlayPane.qml | 14 +- qml/panes/PeerSettingsPane.qml | 12 +- qml/panes/SettingsPane.qml | 10 +- qml/widgets/MyProfile.qml | 8 +- ui.pro | 32 +++++ 13 files changed, 530 insertions(+), 36 deletions(-) create mode 100644 i18n/translation_de.qm create mode 100644 i18n/translation_de.ts create mode 100644 i18n/translation_en.qm create mode 100644 i18n/translation_en.ts create mode 100644 qml.qrc create mode 100644 ui.pro diff --git a/i18n/translation_de.qm b/i18n/translation_de.qm new file mode 100644 index 0000000000000000000000000000000000000000..9dad8dffceb9623e88f8b96d9cd0caf25574c6fa GIT binary patch literal 23 fcmcE7ks@*G{hX<16=n7(EZlpygMop8iIEWihQJ9+ literal 0 HcmV?d00001 diff --git a/i18n/translation_de.ts b/i18n/translation_de.ts new file mode 100644 index 0000000..6ac8e75 --- /dev/null +++ b/i18n/translation_de.ts @@ -0,0 +1,232 @@ + + + + + AddGroupPane + + + Create a new group + + + + + Server: + + + + + Group name: + + + + + my awesome group + + + + + create + + + + + BulletinOverlay + + + New Bulletin + + + + + GroupSettingsPane + + + Server: + + + + + + copy + + + + + Invitation: + + + + + Group name: + + + + + Save + + + + + Invite someone to the group: + + + + + Invite + + + + + delete + + + + + ListOverlay + + + Add a New List Item + + + + + Message + + + Could not send this message: + + + + + Acknowledged + + + + + Pending + + + + + MyProfile + + + copy + + + + + copied to clipboard! + + + + + new group + + + + + ... paste an address here to add a contact ... + + + + + OverlayPane + + + Do you want to accept the invitation to + + + + + Accept + + + + + Reject + + + + + Chat + + + + + Lists + + + + + Bulletins + + + + + Puzzle Game + + + + + PeerSettingsPane + + + Address: + + + + + copy + + + + + copied to clipboard! + + + + + Display name: + + + + + Save + + + + + delete + + + + + SettingsPane + + + Cwtch Settings + + + + + Interface zoom (mostly affects text and button sizes): + + + + + Large text + + + + + Default size text (scale factor: + + + + + Small text + + + + diff --git a/i18n/translation_en.qm b/i18n/translation_en.qm new file mode 100644 index 0000000000000000000000000000000000000000..9dad8dffceb9623e88f8b96d9cd0caf25574c6fa GIT binary patch literal 23 fcmcE7ks@*G{hX<16=n7(EZlpygMop8iIEWihQJ9+ literal 0 HcmV?d00001 diff --git a/i18n/translation_en.ts b/i18n/translation_en.ts new file mode 100644 index 0000000..4c89e42 --- /dev/null +++ b/i18n/translation_en.ts @@ -0,0 +1,191 @@ + + + + + AddGroupPane + + Create a new group + + + + Server: + + + + Group name: + + + + my awesome group + + + + create + + + + + BulletinOverlay + + New Bulletin + + + + + GroupSettingsPane + + Server: + + + + copy + + + + Invitation: + + + + Group name: + + + + Save + + + + Invite someone to the group: + + + + Invite + + + + delete + + + + + ListOverlay + + Add a New List Item + + + + + Message + + Could not send this message: + + + + Acknowledged + + + + Pending + + + + + MyProfile + + copy + + + + copied to clipboard! + + + + new group + + + + ... paste an address here to add a contact ... + + + + + OverlayPane + + Do you want to accept the invitation to + + + + Accept + + + + Reject + + + + Chat + + + + Lists + + + + Bulletins + + + + Puzzle Game + + + + + PeerSettingsPane + + Address: + + + + copy + + + + copied to clipboard! + + + + Display name: + + + + Save + + + + delete + + + + + SettingsPane + + Cwtch Settings + + + + Interface zoom (mostly affects text and button sizes): + + + + Large text + + + + Default size text (scale factor: + + + + Small text + + + + diff --git a/main.go b/main.go index 5dc144a..30ae3c0 100644 --- a/main.go +++ b/main.go @@ -57,6 +57,10 @@ func main() { app := gui.NewQGuiApplication(len(os.Args), os.Args) app.SetWindowIcon(gui.NewQIcon5(":/qml/images/cwtch-icon.png")) + var translator = core.NewQTranslator(nil) + translator.Load("translation_"+core.QLocale_System().Name(), ":/i18n/", "", "") + core.QCoreApplication_InstallTranslator(translator) + core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true) quickcontrols2.QQuickStyle_SetStyle("Universe") engine := qml.NewQQmlApplicationEngine(nil) diff --git a/qml.qrc b/qml.qrc new file mode 100644 index 0000000..13bf602 --- /dev/null +++ b/qml.qrc @@ -0,0 +1,35 @@ + + + qml/overlays/BulletinOverlay.qml + qml/overlays/ChatOverlay.qml + qml/overlays/Game1Overlay.qml + qml/overlays/Game2Overlay.qml + qml/overlays/ListOverlay.qml + qml/main.qml + qml/panes/AddGroupPane.qml + qml/panes/GroupSettingsPane.qml + qml/panes/OverlayPane.qml + qml/panes/PeerSettingsPane.qml + qml/panes/SettingsPane.qml + qml/styles/CwtchComboBoxStyle.qml + qml/styles/CwtchExpandingButton.qml + qml/styles/CwtchTextAreaStyle.qml + qml/styles/CwtchTextFieldStyle.qml + qml/widgets/ContactList.qml + qml/widgets/ContactPicture.qml + qml/widgets/ContactRow.qml + qml/widgets/FontAwesome.qml + qml/widgets/InplaceEditText.qml + qml/widgets/Message.qml + qml/widgets/MyProfile.qml + qml/widgets/ScalingLabel.qml + qml/widgets/SimpleButton.qml + qml/widgets/StackToolbar.qml + qml/widgets/controls/Button.qml + qml/widgets/controls/Loader.qml + qml/widgets/controls/Text.qml + qml/widgets/controls/Variables.qml + i18n/translation_en.qm + i18n/translation_de.qm + + diff --git a/qml/panes/AddGroupPane.qml b/qml/panes/AddGroupPane.qml index 2dea2a9..036aa83 100644 --- a/qml/panes/AddGroupPane.qml +++ b/qml/panes/AddGroupPane.qml @@ -14,7 +14,7 @@ ColumnLayout { // settingsPane StackToolbar { - text: "Create a new group" + text: qsTr("Create a new group") aux.visible: false } @@ -23,7 +23,7 @@ ColumnLayout { // settingsPane spacing: 5 ScalingLabel { - text: "Server:" + text: qsTr("Server:") } TextField { @@ -33,17 +33,17 @@ ColumnLayout { // settingsPane } ScalingLabel{ - text: "Group name:" + text: qsTr("Group name:") } TextField { id: txtGroupName style: CwtchTextFieldStyle{ width: 400 } - text: "my awesome group" + text: qsTr("my awesome group") } SimpleButton { - text: "create" + text: qsTr("create") onClicked: { gcd.createGroup(txtServer.text, txtGroupName.text) diff --git a/qml/panes/GroupSettingsPane.qml b/qml/panes/GroupSettingsPane.qml index c8b55d8..9fdfd62 100644 --- a/qml/panes/GroupSettingsPane.qml +++ b/qml/panes/GroupSettingsPane.qml @@ -27,7 +27,7 @@ ColumnLayout { // groupSettingsPane spacing: 5 ScalingLabel { - text: "Server:" + text: qsTr("Server:") } TextField { @@ -38,7 +38,7 @@ ColumnLayout { // groupSettingsPane SimpleButton { icon: "regular/clipboard" - text: "copy" + text: qsTr("copy") onClicked: { gcd.popup("copied to clipboard!") @@ -48,7 +48,7 @@ ColumnLayout { // groupSettingsPane } ScalingLabel { - text: "Invitation:" + text: qsTr("Invitation:") } TextField { @@ -59,7 +59,7 @@ ColumnLayout { // groupSettingsPane SimpleButton { icon: "regular/clipboard" - text: "copy" + text: qsTr("copy") onClicked: { gcd.popup("copied to clipboard!") @@ -69,7 +69,7 @@ ColumnLayout { // groupSettingsPane } ScalingLabel{ - text: "Group name:" + text: qsTr("Group name:") } TextField { @@ -78,7 +78,7 @@ ColumnLayout { // groupSettingsPane } SimpleButton { - text: "Save" + text: qsTr("Save") onClicked: { gcd.saveGroupSettings(groupID, txtGroupName.text) @@ -87,7 +87,7 @@ ColumnLayout { // groupSettingsPane } } - ScalingLabel { text: "Invite someone to the group:" } + ScalingLabel { text: qsTr("Invite someone to the group:") } ComboBox { id: cbInvite @@ -98,7 +98,7 @@ ColumnLayout { // groupSettingsPane } SimpleButton { - text: "Invite" + text: qsTr("Invite") onClicked: { gcd.inviteToGroup(addrbook[cbInvite.currentIndex], groupID) @@ -107,7 +107,7 @@ ColumnLayout { // groupSettingsPane SimpleButton { icon: "regular/trash-alt" - text: "delete" + text: qsTr("delete") onClicked: { gcd.leaveGroup(groupID) diff --git a/qml/panes/OverlayPane.qml b/qml/panes/OverlayPane.qml index d40c4de..4473d5c 100644 --- a/qml/panes/OverlayPane.qml +++ b/qml/panes/OverlayPane.qml @@ -36,11 +36,11 @@ ColumnLayout { Text { - text: "Do you want to accept the invitation to " + overlay.name + "?" + text: qsTr("Do you want to accept the invitation to ") + overlay.name + "?" } SimpleButton { - text: "Accept" + text: qsTr("Accept") icon: "regular/heart" onClicked: { gcd.acceptGroup(gcd.currentOpenConversation) @@ -49,7 +49,7 @@ ColumnLayout { } SimpleButton { - text: "Reject" + text: qsTr("Reject") icon: "regular/trash-alt" onClicked: { gcd.leaveGroup(gcd.currentOpenConversation) @@ -63,28 +63,28 @@ ColumnLayout { SimpleButton { - text: "Chat" + text: qsTr("Chat") onClicked: overlayStack.overlay = overlayStack.chatOverlay } SimpleButton { - text: "Lists" + text: qsTr("Lists") onClicked: overlayStack.overlay = overlayStack.listOverlay } SimpleButton { - text: "Bulletins" + text: qsTr("Bulletins") onClicked: overlayStack.overlay = overlayStack.bulletinOverlay } SimpleButton { - text: "Puzzle Game" + text: qsTr("Puzzle Game") onClicked: overlayStack.overlay = overlayStack.game1Overlay diff --git a/qml/panes/PeerSettingsPane.qml b/qml/panes/PeerSettingsPane.qml index 33bd763..6feec39 100644 --- a/qml/panes/PeerSettingsPane.qml +++ b/qml/panes/PeerSettingsPane.qml @@ -26,7 +26,7 @@ ColumnLayout { // peerSettingsPane spacing: 5 ScalingLabel { - text: "Address:" + text: qsTr("Address:") } TextField { @@ -37,17 +37,17 @@ ColumnLayout { // peerSettingsPane SimpleButton { icon: "regular/clipboard" - text: "copy" + text: qsTr("copy") onClicked: { - gcd.popup("copied to clipboard!") + gcd.popup(qsTr("copied to clipboard!")) txtOnion.selectAll() txtOnion.copy() } } ScalingLabel{ - text: "Display name:" + text: qsTr("Display name:") } TextField { @@ -56,7 +56,7 @@ ColumnLayout { // peerSettingsPane } SimpleButton { - text: "Save" + text: qsTr("Save") onClicked: { gcd.savePeerSettings(txtOnion.text, txtDisplayName.text) @@ -67,7 +67,7 @@ ColumnLayout { // peerSettingsPane SimpleButton { icon: "regular/trash-alt" - text: "delete" + text: qsTr("delete") onClicked: { gcd.setAttribute(txtOnion.text, "deleted", "deleted") diff --git a/qml/panes/SettingsPane.qml b/qml/panes/SettingsPane.qml index b621e86..8d5c5ff 100644 --- a/qml/panes/SettingsPane.qml +++ b/qml/panes/SettingsPane.qml @@ -13,7 +13,7 @@ ColumnLayout { // settingsPane StackToolbar { - text: "Cwtch Settings" + text: qsTr("Cwtch Settings") aux.visible: false } @@ -23,7 +23,7 @@ ColumnLayout { // settingsPane ScalingLabel { Layout.maximumWidth: parent.width - text: "Interface zoom (mostly affects text and button sizes):" + text: qsTr("Interface zoom (mostly affects text and button sizes):") } Slider { @@ -39,16 +39,16 @@ ColumnLayout { // settingsPane } ScalingLabel { - text: "Large text" + text: qsTr("Large text") size: 20 } ScalingLabel{ - text: "Default size text (scale factor: " + zoomSlider.value + ")" + text: qsTr("Default size text (scale factor: ") + zoomSlider.value + ")" } ScalingLabel { - text: "Small text" + text: qsTr("Small text") size: 8 } diff --git a/qml/widgets/MyProfile.qml b/qml/widgets/MyProfile.qml index 5b2b1dd..8c40a43 100644 --- a/qml/widgets/MyProfile.qml +++ b/qml/widgets/MyProfile.qml @@ -165,10 +165,10 @@ ColumnLayout { SimpleButton { // COPY ONION ADDRESS BUTTON icon: "regular/clipboard" - text: "copy" + text: qsTr("copy") onClicked: { - gcd.popup("copied to clipboard!") + gcd.popup(qsTr("copied to clipboard!")) txtHidden.text = nick.replace(" ", "~") + "~" + onion txtHidden.selectAll() txtHidden.copy() @@ -197,7 +197,7 @@ ColumnLayout { SimpleButton { // CREATE GROUP BUTTON icon: "regular/clipboard" - text: "new group" + text: qsTr("new group") onClicked: theStack.pane = theStack.addGroupPane } @@ -206,7 +206,7 @@ ColumnLayout { TextField { anchors.horizontalCenter: parent.horizontalCenter style: CwtchTextFieldStyle{ width: 400 } - placeholderText: "... paste an address here to add a contact ..." + placeholderText: qsTr("... paste an address here to add a contact ...") horizontalAlignment: TextInput.AlignHCenter onTextChanged: { diff --git a/ui.pro b/ui.pro new file mode 100644 index 0000000..a38e9ad --- /dev/null +++ b/ui.pro @@ -0,0 +1,32 @@ +QT += quick + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which as been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.go + +RESOURCES += qml.qrc + +TRANSLATIONS = i18n/translation_en.ts \ + i18n/translation_de.ts + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = + +# Additional import path used to resolve QML modules just for Qt Quick Designer +QML_DESIGNER_IMPORT_PATH = + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target +