Skip to content

Commit

Permalink
Integrated arabic translation & adapted Librum to RTL align correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLazarescu committed Feb 6, 2024
1 parent eca66b8 commit 1bf0f25
Show file tree
Hide file tree
Showing 25 changed files with 267 additions and 600 deletions.
1 change: 0 additions & 1 deletion scripts/update_translations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ TRANSLATION_FILES=$(find "$SCRIPT_DIR/../src/presentation/translations" -name "l

# Use lupdate with the list of translation files
lupdate "$SCRIPT_DIR/../src/presentation" -ts $TRANSLATION_FILES

4 changes: 1 addition & 3 deletions src/adapters/controllers/app_info_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ bool AppInfoController::switchToLanguage(const QString& language)
return false;
}


emit languageChanged();

// Use "English" for all kinds of English variants like American English
if(QLocale(language).language() == QLocale::Language::English)
m_language = "English";
Expand All @@ -167,6 +164,7 @@ bool AppInfoController::switchToLanguage(const QString& language)
settings.setValue("language", language);

m_engine->retranslate();
emit languageChanged();
return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/presentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(translation_files
translations/librum_en.ts
translations/librum_de.ts
translations/librum_ru.ts
translations/librum_ar.ts
translations/librum_zh.ts
)
qt_add_translations(presentation TS_FILES ${translation_files})
Expand Down
4 changes: 4 additions & 0 deletions src/presentation/LanguageModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ ListModel {
text: "Deutsch"
code: "de"
}
ListElement {
text: "العربية"
code: "ar"
}
ListElement {
text: "Русский"
code: "ru"
Expand Down
7 changes: 5 additions & 2 deletions src/presentation/freeBooksPage/MFreeBooksPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Page {

function onFetchingFirstMetadataPageSuccessful(success) {
if (!success) {
errorMessageLabel.text
= qsTr("Couldn't load free books. Please, check your network connection")
errorMessageLabel.text = qsTr(
"Couldn't load free books. Please, check your network connection")
errorMessageLabel.visible = true
}

Expand Down Expand Up @@ -124,6 +124,9 @@ Page {
cellHeight: internal.bookHeight + internal.verticalBookSpacing
// Negative margin removes the extra spacing at the right of the grid
rightMargin: -internal.horizontalBookSpacing
layoutDirection: Qt.LeftToRight
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true
interactive: true
boundsBehavior: Flickable.StopAtBounds
flickDeceleration: 19500
Expand Down
5 changes: 5 additions & 0 deletions src/presentation/homePage/MHomePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Page {
horizontalPadding: 64
rightPadding: 70
bottomPadding: 20
LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true
background: Rectangle {
anchors.fill: parent
color: Style.colorPageBackground
Expand Down Expand Up @@ -178,6 +180,9 @@ Page {
cellWidth: internal.bookWidth + internal.horizontalBookSpacing
cellHeight: internal.bookHeight + internal.verticalBookSpacing
rightMargin: -internal.horizontalBookSpacing
layoutDirection: Qt.LeftToRight
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true
interactive: true
boundsBehavior: Flickable.StopAtBounds
flickDeceleration: 15000
Expand Down
3 changes: 3 additions & 0 deletions src/presentation/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ApplicationWindow {
property int sidebarOpenedMinWidth: 810
property int readingPageMinWidth: 550
property bool notifyAboutUpdates: true
property bool rightAlign: AppInfoController.language === "العربية"

minimumHeight: 400
minimumWidth: 650
Expand All @@ -39,6 +40,8 @@ ApplicationWindow {
id: mainlayout
anchors.fill: parent
spacing: 0
LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

MSidebar {
id: sidebar
Expand Down
3 changes: 3 additions & 0 deletions src/presentation/modules/CustomComponents/MBaseListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Item {

Component.onCompleted: root.completed(model.index, root.actualWidth)

LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

Pane {
id: container
property bool renameable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Popup {
Label {
id: infoText
Layout.topMargin: 20
Layout.leftMargin: 52
Layout.leftMargin: baseRoot.rightAlign ? 0 : 52
Layout.rightMargin: baseRoot.rightAlign ? 52 : 0
Layout.fillWidth: true
wrapMode: Text.WordWrap
textFormat: Text.RichText
Expand Down
53 changes: 24 additions & 29 deletions src/presentation/modules/CustomComponents/MLabeledCheckBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import QtQuick.Layouts
import Librum.style
import Librum.icons


/**
A component which extends MCheckBox by adding a label next to it
*/
Item
{
Item {
id: root
property int boxWidth: 22
property int boxHeight: 22
Expand All @@ -27,29 +27,28 @@ Item
property int verticalTextOffset: 0
property color fontColor: Style.colorText
property alias enabled: checkBox.enabled
signal clicked()
signal clicked

implicitWidth: 100
implicitHeight: layout.height


RowLayout
{

LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

RowLayout {
id: layout
width: parent.width
spacing: root.spacing


MCheckBox
{

MCheckBox {
id: checkBox
Layout.preferredWidth: root.boxWidth
Layout.preferredHeight: root.boxHeight

onClicked: root.clicked()
}

Label
{

Label {
id: text
Layout.preferredWidth: root.width
Layout.topMargin: root.verticalTextOffset
Expand All @@ -58,23 +57,19 @@ Item
font.pointSize: root.fontSize
color: root.fontColor
wrapMode: Text.WordWrap

MouseArea
{
width: text.implicitWidth
height: text.implicitHeight


MouseArea {
anchors.fill: parent

onClicked: {
checkBox.toggle()
root.clicked()
}
}
}
}


function giveFocus()
{
root.forceActiveFocus();
}
}

function giveFocus() {
root.forceActiveFocus()
}
}
3 changes: 3 additions & 0 deletions src/presentation/modules/CustomComponents/buttons/MButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Item {
property bool centerContentVertically: true
property bool centerContentHorizontally: true

LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

implicitHeight: 30
implicitWidth: layout.implicitWidth + 2 * horizontalMargins

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Item {
implicitHeight: 32
implicitWidth: 100

LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

onVisibleChanged: selected = false

Pane {
Expand Down
4 changes: 4 additions & 0 deletions src/presentation/readingPage/MReadingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Page {
color: Style.colorPageBackground
}

// Prevent right-alignment
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true

Component.onCompleted: root.forceActiveFocus()
Component.onDestruction: internal.saveCurrentPage()

Expand Down
5 changes: 2 additions & 3 deletions src/presentation/settings/MAboutPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ MFlickWrapper {
id: heartRow
Layout.fillWidth: true
Layout.topMargin: 40
spacing: 0
spacing: 22

Image {
id: heartImage
Expand All @@ -278,8 +278,7 @@ MFlickWrapper {

Label {
id: thisAppText
Layout.fillWidth: true
Layout.leftMargin: 22
Layout.alignment: baseRoot.rightAlign ? Qt.AlignRight : Qt.AlignLeft
text: qsTr("Librum is here for everyone who just wants to enjoy a good book.\n" + "We hope you have a great time using it! Feel free to leave us a rating and some feedback.")
wrapMode: Text.WordWrap
color: Style.colorText
Expand Down
3 changes: 3 additions & 0 deletions src/presentation/settings/MSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Page {
property alias storagePage: storagePage
property alias supportUsPage: supportUsPage

LayoutMirroring.enabled: baseRoot.rightAlign
LayoutMirroring.childrenInherit: true

background: Rectangle {
anchors.fill: parent
color: Style.colorPageBackground
Expand Down
4 changes: 4 additions & 0 deletions src/presentation/settings/shortcutsPage/MShortcutsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Page {
anchors.fill: parent
spacing: 0

// Prevent right-alignment
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true


/*
The shortcuts header labeling the different columns
Expand Down
1 change: 1 addition & 0 deletions src/presentation/settings/updatesPage/MUpToDate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Item {
Label {
Layout.fillWidth: true
text: AppInfoController.currentVersion
horizontalAlignment: Text.AlignLeft
wrapMode: Text.WordWrap
color: Style.colorBasePurple
font.pointSize: Fonts.size14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Item {
Label {
Layout.fillWidth: true
text: AppInfoController.newestVersion
horizontalAlignment: Text.AlignLeft
wrapMode: Text.WordWrap
color: Style.colorLightText
font.pointSize: Fonts.size14
Expand Down
7 changes: 6 additions & 1 deletion src/presentation/sidebar/MSidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ Item {
*/
MProfilePopup {
id: profilePopup
x: 12
x: {
if (baseRoot.rightAlign)
return -106
else
return 12
}
y: profileBox.y - implicitHeight + 6
}
}
Expand Down
Loading

0 comments on commit 1bf0f25

Please sign in to comment.