Skip to content

Commit a75557d

Browse files
linux(i18n): add Turkish translations (#361)
* linux(i18n): add Turkish translations - Add Qt Linguist translation infrastructure to CMakeLists.txt - Wrap UI strings with qsTr() in Main.qml - Wrap menu strings with tr() in trayiconmanager.cpp - Add QTranslator loader in main.cpp for automatic locale detection - Create Turkish translation file (librepods_tr.ts) Translations include: - Main window: connection status, noise control modes, settings - Tray menu: all menu items and tooltips - System notifications * fix: allocate QTranslator on heap to ensure lifetime
1 parent 0e1f784 commit a75557d

File tree

5 files changed

+217
-28
lines changed

5 files changed

+217
-28
lines changed

linux/CMakeLists.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ project(linux VERSION 0.1 LANGUAGES CXX)
44

55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

7-
find_package(Qt6 REQUIRED COMPONENTS Quick Widgets Bluetooth DBus)
7+
find_package(Qt6 REQUIRED COMPONENTS Quick Widgets Bluetooth DBus LinguistTools)
88
find_package(OpenSSL REQUIRED)
99
find_package(PkgConfig REQUIRED)
1010
pkg_check_modules(PULSEAUDIO REQUIRED libpulse)
1111

1212
qt_standard_project_setup()
1313

14+
# Translation files
15+
set(TS_FILES
16+
translations/librepods_tr.ts
17+
)
18+
1419
qt_add_executable(librepods
1520
main.cpp
1621
logger.h
@@ -85,3 +90,13 @@ install(FILES assets/me.kavishdevar.librepods.desktop
8590
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
8691
install(FILES assets/librepods.png
8792
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps")
93+
94+
# Translation support
95+
qt_add_translations(librepods
96+
TS_FILES ${TS_FILES}
97+
QM_FILES_OUTPUT_VARIABLE QM_FILES
98+
)
99+
100+
# Install translation files
101+
install(FILES ${QM_FILES}
102+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/librepods/translations")

linux/Main.qml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ApplicationWindow {
8181

8282
Label {
8383
anchors.centerIn: parent
84-
text: airPodsTrayApp.airpodsConnected ? "Connected" : "Disconnected"
84+
text: airPodsTrayApp.airpodsConnected ? qsTr("Connected") : qsTr("Disconnected")
8585
color: "white"
8686
font.pixelSize: 12
8787
font.weight: Font.Medium
@@ -130,7 +130,7 @@ ApplicationWindow {
130130

131131
SegmentedControl {
132132
anchors.horizontalCenter: parent.horizontalCenter
133-
model: ["Off", "Noise Cancellation", "Transparency", "Adaptive"]
133+
model: [qsTr("Off"), qsTr("Noise Cancellation"), qsTr("Transparency"), qsTr("Adaptive")]
134134
currentIndex: airPodsTrayApp.deviceInfo.noiseControlMode
135135
onCurrentIndexChanged: airPodsTrayApp.setNoiseControlModeInt(currentIndex)
136136
visible: airPodsTrayApp.airpodsConnected
@@ -153,21 +153,21 @@ ApplicationWindow {
153153
onValueChanged: if (pressed) debounceTimer.restart()
154154

155155
Label {
156-
text: "Adaptive Noise Level: " + parent.value
156+
text: qsTr("Adaptive Noise Level: ") + parent.value
157157
anchors.top: parent.bottom
158158
}
159159
}
160160

161161
Switch {
162162
visible: airPodsTrayApp.airpodsConnected
163-
text: "Conversational Awareness"
163+
text: qsTr("Conversational Awareness")
164164
checked: airPodsTrayApp.deviceInfo.conversationalAwareness
165165
onCheckedChanged: airPodsTrayApp.setConversationalAwareness(checked)
166166
}
167167

168168
Switch {
169169
visible: airPodsTrayApp.airpodsConnected
170-
text: "Hearing Aid"
170+
text: qsTr("Hearing Aid")
171171
checked: airPodsTrayApp.deviceInfo.hearingAidEnabled
172172
onCheckedChanged: airPodsTrayApp.setHearingAidEnabled(checked)
173173
}
@@ -189,7 +189,7 @@ ApplicationWindow {
189189
id: settingsPage
190190
Page {
191191
id: settingsPageItem
192-
title: "Settings"
192+
title: qsTr("Settings")
193193

194194
ScrollView {
195195
anchors.fill: parent
@@ -200,7 +200,7 @@ ApplicationWindow {
200200
padding: 20
201201

202202
Label {
203-
text: "Settings"
203+
text: qsTr("Settings")
204204
font.pixelSize: 24
205205
// center the label
206206
anchors.horizontalCenter: parent.horizontalCenter
@@ -210,54 +210,54 @@ ApplicationWindow {
210210
spacing: 5 // Small gap between label and ComboBox
211211

212212
Label {
213-
text: "Pause Behavior When Removing AirPods:"
213+
text: qsTr("Pause Behavior When Removing AirPods:")
214214
}
215215

216216
ComboBox {
217217
width: parent.width // Ensures full width
218-
model: ["One Removed", "Both Removed", "Never"]
218+
model: [qsTr("One Removed"), qsTr("Both Removed"), qsTr("Never")]
219219
currentIndex: airPodsTrayApp.earDetectionBehavior
220220
onActivated: airPodsTrayApp.earDetectionBehavior = currentIndex
221221
}
222222
}
223223

224224
Switch {
225-
text: "Cross-Device Connectivity with Android"
225+
text: qsTr("Cross-Device Connectivity with Android")
226226
checked: airPodsTrayApp.crossDeviceEnabled
227227
onCheckedChanged: {
228228
airPodsTrayApp.setCrossDeviceEnabled(checked)
229229
}
230230
}
231231

232232
Switch {
233-
text: "Auto-Start on Login"
233+
text: qsTr("Auto-Start on Login")
234234
checked: airPodsTrayApp.autoStartManager.autoStartEnabled
235235
onCheckedChanged: airPodsTrayApp.autoStartManager.autoStartEnabled = checked
236236
}
237237

238238
Switch {
239-
text: "Enable System Notifications"
239+
text: qsTr("Enable System Notifications")
240240
checked: airPodsTrayApp.notificationsEnabled
241241
onCheckedChanged: airPodsTrayApp.notificationsEnabled = checked
242242
}
243243

244244
Switch {
245245
visible: airPodsTrayApp.airpodsConnected
246-
text: "One Bud ANC Mode"
246+
text: qsTr("One Bud ANC Mode")
247247
checked: airPodsTrayApp.deviceInfo.oneBudANCMode
248248
onCheckedChanged: airPodsTrayApp.deviceInfo.oneBudANCMode = checked
249249

250250
ToolTip {
251251
visible: parent.hovered
252-
text: "Enable ANC when using one AirPod\n(More noise reduction, but uses more battery)"
252+
text: qsTr("Enable ANC when using one AirPod\n(More noise reduction, but uses more battery)")
253253
delay: 500
254254
}
255255
}
256256

257257
Row {
258258
spacing: 5
259259
Label {
260-
text: "Bluetooth Retry Attempts:"
260+
text: qsTr("Bluetooth Retry Attempts:")
261261
anchors.verticalCenter: parent.verticalCenter
262262
}
263263
SpinBox {
@@ -279,7 +279,7 @@ ApplicationWindow {
279279
}
280280

281281
Button {
282-
text: "Rename"
282+
text: qsTr("Rename")
283283
onClicked: airPodsTrayApp.renameAirPods(newNameField.text)
284284
}
285285
}
@@ -295,14 +295,14 @@ ApplicationWindow {
295295
}
296296

297297
Button {
298-
text: "Change Phone MAC"
298+
text: qsTr("Change Phone MAC")
299299
onClicked: airPodsTrayApp.setPhoneMac(newPhoneMacField.text)
300300
}
301301
}
302302

303303

304304
Button {
305-
text: "Show Magic Cloud Keys QR"
305+
text: qsTr("Show Magic Cloud Keys QR")
306306
onClicked: keysQrDialog.show()
307307
}
308308

linux/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include <QTimer>
1313
#include <QProcess>
1414
#include <QRegularExpression>
15+
#include <QTranslator>
16+
#include <QLibraryInfo>
17+
#include <QDir>
18+
#include <QStandardPaths>
1519

1620
#include "airpods_packets.h"
1721
#include "logger.h"
@@ -987,6 +991,25 @@ private slots:
987991
int main(int argc, char *argv[]) {
988992
QApplication app(argc, argv);
989993

994+
// Load translations
995+
QTranslator *translator = new QTranslator(&app);
996+
QString locale = QLocale::system().name();
997+
998+
// Try to load translation from various locations
999+
QStringList translationPaths = {
1000+
QCoreApplication::applicationDirPath() + "/translations",
1001+
QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/librepods/translations",
1002+
"/usr/share/librepods/translations",
1003+
"/usr/local/share/librepods/translations"
1004+
};
1005+
1006+
for (const QString &path : translationPaths) {
1007+
if (translator->load("librepods_" + locale, path)) {
1008+
app.installTranslator(translator);
1009+
break;
1010+
}
1011+
}
1012+
9901013
QLocalServer::removeServer("app_server");
9911014

9921015
QFile stale("/tmp/app_server");

linux/translations/librepods_tr.ts

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="tr_TR">
4+
<context>
5+
<name>Main</name>
6+
<message>
7+
<source>Connected</source>
8+
<translation>Bağlı</translation>
9+
</message>
10+
<message>
11+
<source>Disconnected</source>
12+
<translation>Bağlantı Kesildi</translation>
13+
</message>
14+
<message>
15+
<source>Off</source>
16+
<translation>Kapalı</translation>
17+
</message>
18+
<message>
19+
<source>Noise Cancellation</source>
20+
<translation>Gürültü Engelleme</translation>
21+
</message>
22+
<message>
23+
<source>Transparency</source>
24+
<translation>Şeffaflık</translation>
25+
</message>
26+
<message>
27+
<source>Adaptive</source>
28+
<translation>Uyarlanabilir</translation>
29+
</message>
30+
<message>
31+
<source>Adaptive Noise Level: </source>
32+
<translation>Uyarlanabilir Gürültü Seviyesi: </translation>
33+
</message>
34+
<message>
35+
<source>Conversational Awareness</source>
36+
<translation>Konuşma Farkındalığı</translation>
37+
</message>
38+
<message>
39+
<source>Hearing Aid</source>
40+
<translation>İşitme Cihazı</translation>
41+
</message>
42+
<message>
43+
<source>Settings</source>
44+
<translation>Ayarlar</translation>
45+
</message>
46+
<message>
47+
<source>Pause Behavior When Removing AirPods:</source>
48+
<translation>AirPods Çıkarıldığında Duraklatma Davranışı:</translation>
49+
</message>
50+
<message>
51+
<source>One Removed</source>
52+
<translation>Biri Çıkarıldığında</translation>
53+
</message>
54+
<message>
55+
<source>Both Removed</source>
56+
<translation>İkisi de Çıkarıldığında</translation>
57+
</message>
58+
<message>
59+
<source>Never</source>
60+
<translation>Asla</translation>
61+
</message>
62+
<message>
63+
<source>Cross-Device Connectivity with Android</source>
64+
<translation>Android ile Çapraz Cihaz Bağlantısı</translation>
65+
</message>
66+
<message>
67+
<source>Auto-Start on Login</source>
68+
<translation>Oturum Açıldığında Otomatik Başlat</translation>
69+
</message>
70+
<message>
71+
<source>Enable System Notifications</source>
72+
<translation>Sistem Bildirimlerini Etkinleştir</translation>
73+
</message>
74+
<message>
75+
<source>One Bud ANC Mode</source>
76+
<translation>Tek Kulaklık ANC Modu</translation>
77+
</message>
78+
<message>
79+
<source>Enable ANC when using one AirPod
80+
(More noise reduction, but uses more battery)</source>
81+
<translation>Tek AirPod kullanırken ANC&apos;yi etkinleştir
82+
(Daha fazla gürültü azaltma, ancak daha fazla pil kullanır)</translation>
83+
</message>
84+
<message>
85+
<source>Bluetooth Retry Attempts:</source>
86+
<translation>Bluetooth Yeniden Deneme Sayısı:</translation>
87+
</message>
88+
<message>
89+
<source>Rename</source>
90+
<translation>Yeniden Adlandır</translation>
91+
</message>
92+
<message>
93+
<source>Change Phone MAC</source>
94+
<translation>Telefon MAC Adresini Değiştir</translation>
95+
</message>
96+
<message>
97+
<source>Show Magic Cloud Keys QR</source>
98+
<translation>Magic Cloud Anahtarları QR&apos;ını Göster</translation>
99+
</message>
100+
</context>
101+
<context>
102+
<name>TrayIconManager</name>
103+
<message>
104+
<source>Battery Status: </source>
105+
<translation>Pil Durumu: </translation>
106+
</message>
107+
<message>
108+
<source>Open</source>
109+
<translation>Aç</translation>
110+
</message>
111+
<message>
112+
<source>Settings</source>
113+
<translation>Ayarlar</translation>
114+
</message>
115+
<message>
116+
<source>Toggle Conversational Awareness</source>
117+
<translation>Konuşma Farkındalığını Aç/Kapat</translation>
118+
</message>
119+
<message>
120+
<source>Adaptive</source>
121+
<translation>Uyarlanabilir</translation>
122+
</message>
123+
<message>
124+
<source>Transparency</source>
125+
<translation>Şeffaflık</translation>
126+
</message>
127+
<message>
128+
<source>Noise Cancellation</source>
129+
<translation>Gürültü Engelleme</translation>
130+
</message>
131+
<message>
132+
<source>Off</source>
133+
<translation>Kapalı</translation>
134+
</message>
135+
<message>
136+
<source>Quit</source>
137+
<translation>Çıkış</translation>
138+
</message>
139+
</context>
140+
<context>
141+
<name>AirPodsTrayApp</name>
142+
<message>
143+
<source>AirPods Disconnected</source>
144+
<translation>AirPods Bağlantısı Kesildi</translation>
145+
</message>
146+
<message>
147+
<source>Your AirPods have been disconnected</source>
148+
<translation>AirPods&apos;unuzun bağlantısı kesildi</translation>
149+
</message>
150+
</context>
151+
</TS>

0 commit comments

Comments
 (0)