Skip to content

Commit 1019d64

Browse files
committed
Added french translation
1 parent 1f31aef commit 1019d64

File tree

12 files changed

+202
-39
lines changed

12 files changed

+202
-39
lines changed

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"justMyCode": false,
2929
"env": {
3030
"QT_COLOR_MODE": "light",
31+
// "LANG": "fr",
3132
}
3233
},
3334
{

cdlclient/config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Licensed under the terms of the BSD 3-Clause
4+
# (see cdlclient/LICENSE for details)
5+
6+
"""
7+
DataLab Simple Client configuration module
8+
------------------------------------------
9+
10+
This module handles `DataLab Simple Client` configuration.
11+
"""
12+
13+
from __future__ import annotations
14+
15+
import os.path as osp
16+
17+
from guidata import configtools
18+
19+
MOD_NAME = "cdlclient"
20+
_ = configtools.get_translation(MOD_NAME)
21+
22+
MOD_PATH = configtools.get_module_data_path(MOD_NAME)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# -*- coding: utf-8 -*-
2+
# cdl module translation file
3+
#
4+
msgid ""
5+
msgstr ""
6+
"Project-Id-Version: PACKAGE VERSION\n"
7+
"POT-Creation-Date: 2023-11-23 17:34+0100\n"
8+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
10+
"Language-Team: LANGUAGE <[email protected]>\n"
11+
"Language: \n"
12+
"MIME-Version: 1.0\n"
13+
"Content-Type: text/plain; charset=utf-8\n"
14+
"Content-Transfer-Encoding: utf-8\n"
15+
"Generated-By: pygettext.py 1.5\n"
16+
17+
#: cdlclient\tests\remoteclient_app.py:62
18+
msgid "This the client application, which connects to DataLab."
19+
msgstr "Ceci l'application cliente, qui se connecte à DataLab."
20+
21+
#: cdlclient\tests\remoteclient_app.py:63
22+
msgid "Connect to DataLab"
23+
msgstr "Se connecter à DataLab"
24+
25+
#: cdlclient\tests\remoteclient_app.py:100
26+
msgid "Execute multiple commands"
27+
msgstr "Exécuter des commandes multiples"
28+
29+
#: cdlclient\tests\remoteclient_app.py:101
30+
msgid "Get object titles"
31+
msgstr "Obtenir la liste des titres"
32+
33+
#: cdlclient\tests\remoteclient_app.py:102
34+
msgid "Get object uuids"
35+
msgstr "Obtenir la liste des uuids"
36+
37+
#: cdlclient\tests\remoteclient_app.py:103
38+
msgid "Get object"
39+
msgstr "Obtenir un objet"
40+
41+
#: cdlclient\tests\remoteclient_app.py:104
42+
msgid "Get object using dialog box"
43+
msgstr "Obtenir un objet en utilisant une boîte de dialogue"
44+
45+
#: cdlclient\tests\remoteclient_base.py:88
46+
msgid "Host application"
47+
msgstr "Application hôte"
48+
49+
#: cdlclient\tests\remoteclient_base.py:115
50+
msgid "Raise window"
51+
msgstr "Mettre la fenêtre au premier plan"
52+
53+
#: cdlclient\tests\remoteclient_base.py:117
54+
msgid "Add signal objects"
55+
msgstr "Ajouter des objets signal"
56+
57+
#: cdlclient\tests\remoteclient_base.py:118
58+
msgid "Add image objects"
59+
msgstr "Ajouter des objets image"
60+
61+
#: cdlclient\tests\remoteclient_base.py:119
62+
msgid "Remove all objects"
63+
msgstr "Supprimer tous les objets"
64+
65+
#: cdlclient\tests\remoteclient_base.py:120
66+
msgid "Close DataLab"
67+
msgstr "Fermer DataLab"
68+
69+
#: cdlclient\widgets\connection.py:58
70+
msgid "Connection to DataLab"
71+
msgstr "Connexion à DataLab"
72+
73+
#: cdlclient\widgets\connection.py:70
74+
msgid "Waiting for connection..."
75+
msgstr "En attente de connexion..."
76+
77+
#: cdlclient\widgets\connection.py:101
78+
msgid "Connecting to server..."
79+
msgstr "Connexion au serveur..."
80+
81+
#: cdlclient\widgets\connection.py:109
82+
msgid "Connection successful!"
83+
msgstr "Connecté avec succès !"
84+
85+
#: cdlclient\widgets\connection.py:117
86+
msgid "Connection failed."
87+
msgstr "Echec de la connexion."
88+
89+
#: cdlclient\widgets\objectdialog.py:174
90+
msgid "Select object"
91+
msgstr "Sélectionner un objet"
92+
93+
#: cdlclient\widgets\objectdialog.py:191
94+
msgid "Signals"
95+
msgstr "Signaux"
96+
97+
#: cdlclient\widgets\objectdialog.py:192
98+
msgid "Images"
99+
msgstr "Images"
100+
101+
#: cdlclient\widgets\objectdialog.py:196
102+
msgid "Active panel:"
103+
msgstr "Panneau actif :"
104+
105+
#~ msgid "Get object from DataLab"
106+
#~ msgstr "Obtenir un objet depuis DataLab"
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# -*- coding: utf-8 -*-
2+
#
3+
# Licensed under the terms of the BSD 3-Clause
4+
# (see cdlclient/LICENSE for details)
5+
26
"""Qt helpers"""
37

48
from __future__ import annotations
@@ -13,8 +17,9 @@
1317
from qtpy import QtSvg as QS
1418
from qtpy import QtWidgets as QW
1519

16-
PKG_PATH = osp.join(osp.dirname(__file__), os.pardir, os.pardir)
17-
WIDGETS_PATH = osp.join(PKG_PATH, "cdlclient", "widgets")
20+
from cdlclient.config import MOD_PATH
21+
22+
WIDGETS_PATH = osp.join(MOD_PATH, "widgets")
1823

1924

2025
def svgtext_to_icon(text: str) -> QG.QIcon:
@@ -77,14 +82,14 @@ def imagefile_to_python_module(filename: str, destmod: str) -> None:
7782
"""
7883
data = imagefile_to_base64(filename)
7984
destmod_path = osp.join(WIDGETS_PATH, destmod + ".py")
85+
if osp.isfile(destmod_path):
86+
os.remove(destmod_path)
8087
with open(destmod_path, "wb") as fn:
8188
fn.write("# -*- coding: utf-8 -*-\n\n".encode("utf-8"))
8289
fn.write("# pylint: skip-file\n\n".encode("utf-8"))
8390
fn.write("DATA = b'".encode("utf-8"))
8491
fn.write(data)
8592
fn.write("'".encode("utf-8"))
86-
fn.write(data)
87-
fn.write("'".encode("utf-8"))
8893

8994

9095
@contextmanager
@@ -99,3 +104,5 @@ def block_signals(widget: QW.QWidget, enable: bool) -> Generator[None, None, Non
99104
if enable:
100105
widget.blockSignals(False)
101106
widget.blockSignals(False)
107+
widget.blockSignals(False)
108+
widget.blockSignals(False)

cdlclient/tests/get_object_dialog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_dialog():
2020
proxy = SimpleRemoteProxy()
2121
proxy.connect()
2222
with qt_app_context():
23-
dlg = GetObjectDialog(None, "Get object", proxy)
23+
dlg = GetObjectDialog(None, proxy)
2424
if dlg.exec():
2525
obj_uuid = dlg.get_current_object_uuid()
2626
obj = proxy.get_object(obj_uuid)

cdlclient/tests/imagefile_to_code.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33

44
# guitest: skip
55

6+
import os
67
import os.path as osp
78

89
from guidata.qthelpers import qt_app_context
910
from qtpy import QtCore as QC
1011
from qtpy import QtGui as QG
1112
from qtpy import QtWidgets as QW
1213

13-
from cdlclient.widgets.qthelpers import PKG_PATH, imagefile_to_python_module
14+
from cdlclient.config import MOD_NAME, MOD_PATH
15+
from cdlclient.qthelpers import imagefile_to_python_module
1416

15-
RES_PATH = osp.join(PKG_PATH, "resources")
17+
RES_PATH = osp.join(MOD_PATH, os.pardir, "resources")
1618

1719

1820
def test_conv(filename: str, destmod: str) -> None:
@@ -30,7 +32,7 @@ def test_conv(filename: str, destmod: str) -> None:
3032
label1.setPixmap(QG.QPixmap(filename))
3133
label2 = QW.QLabel()
3234
imagefile_to_python_module(filename, destmod)
33-
mod = __import__("cdlclient.widgets." + destmod, fromlist=[destmod])
35+
mod = __import__(f"{MOD_NAME}.widgets.{destmod}", fromlist=[destmod])
3436
pixmap = QG.QPixmap()
3537
pixmap.loadFromData(QC.QByteArray.fromBase64(mod.DATA))
3638
label2.setPixmap(pixmap)
@@ -41,4 +43,3 @@ def test_conv(filename: str, destmod: str) -> None:
4143

4244
if __name__ == "__main__":
4345
test_conv(osp.join(RES_PATH, "DataLab-Banner-200.png"), "datalab_banner")
44-
test_conv(osp.join(RES_PATH, "DataLab-Banner-200.png"), "datalab_banner")

cdlclient/tests/remoteclient_app.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from qtpy import QtWidgets as QW
2424

2525
from cdlclient import SimpleRemoteProxy
26+
from cdlclient.config import _
2627
from cdlclient.tests.remoteclient_base import AbstractClientWindow
2728
from cdlclient.tests.remoteclient_unit import multiple_commands
2829
from cdlclient.widgets import ConnectionDialog, GetObjectDialog
@@ -58,8 +59,8 @@ def method_wrapper(*args, **kwargs):
5859
class HostWindow(AbstractClientWindow):
5960
"""Test main view"""
6061

61-
PURPOSE = "This the client application, which connects to DataLab."
62-
INIT_BUTTON_LABEL = "Connect to DataLab"
62+
PURPOSE = _("This the client application, which connects to DataLab.")
63+
INIT_BUTTON_LABEL = _("Connect to DataLab")
6364
SIG_TITLES = ("Oscilloscope", "Digitizer", "Radiometer", "Voltmeter", "Sensor")
6465
IMA_TITLES = (
6566
"Camera",
@@ -96,11 +97,11 @@ def close_cdl(self):
9697
def add_additional_buttons(self):
9798
"""Add additional buttons"""
9899
add_btn = self.host.add_button
99-
add_btn("Execute multiple commands", self.exec_multiple_cmd, 10)
100-
add_btn("Get object titles", self.get_object_titles, 10)
101-
add_btn("Get object uuids", self.get_object_uuids, 10)
102-
add_btn("Get object", self.get_object)
103-
add_btn("Get object using dialog box", self.get_object_dialog)
100+
add_btn(_("Execute multiple commands"), self.exec_multiple_cmd, 10)
101+
add_btn(_("Get object titles"), self.get_object_titles, 10)
102+
add_btn(_("Get object uuids"), self.get_object_uuids, 10)
103+
add_btn(_("Get object"), self.get_object)
104+
add_btn(_("Get object using dialog box"), self.get_object_dialog)
104105

105106
@try_send_command()
106107
def exec_multiple_cmd(self):
@@ -150,7 +151,7 @@ def get_object(self):
150151
def get_object_dialog(self):
151152
"""Get object (signal/image) using dialog box"""
152153
if self.cdl is not None:
153-
dialog = GetObjectDialog(self, "Get object from DataLab", self.cdl)
154+
dialog = GetObjectDialog(self, self.cdl)
154155
if dialog.exec():
155156
uuid = dialog.get_current_object_uuid()
156157
obj = self.cdl.get_object(uuid)

cdlclient/tests/remoteclient_base.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from guidata.widgets.codeeditor import CodeEditor
1717
from qtpy import QtWidgets as QW
1818

19+
from cdlclient.config import _
20+
1921

2022
class HostWidget(QW.QWidget):
2123
"""Host widget: menu with action buttons, log viewer"""
@@ -83,7 +85,7 @@ class AbstractClientWindow(QW.QMainWindow, metaclass=AbstractClientWindowMeta):
8385
def __init__(self):
8486
super().__init__()
8587
win32_fix_title_bar_background(self)
86-
self.setWindowTitle("Host application")
88+
self.setWindowTitle(_("Host application"))
8789
self.setWindowIcon(get_std_icon("ComputerIcon"))
8890
self.cdl = None # CDLMainWindow instance
8991
self.host = HostWidget(self)
@@ -110,12 +112,12 @@ def setup_window(self):
110112
self.host.add_label(self.PURPOSE)
111113
add_btn = self.host.add_button
112114
add_btn(self.INIT_BUTTON_LABEL, self.init_cdl, 10, "DialogApplyButton")
113-
add_btn("Raise window", self.raise_cdl, 0, "FileDialogToParent")
115+
add_btn(_("Raise window"), self.raise_cdl, 0, "FileDialogToParent")
114116
self.add_additional_buttons()
115-
add_btn("Add signal objects", self.add_signals, 10, "CommandLink")
116-
add_btn("Add image objects", self.add_images, 0, "CommandLink")
117-
add_btn("Remove all objects", self.remove_all, 5, "MessageBoxWarning")
118-
add_btn("Close DataLab", self.close_cdl, 10, "DialogCloseButton")
117+
add_btn(_("Add signal objects"), self.add_signals, 10, "CommandLink")
118+
add_btn(_("Add image objects"), self.add_images, 0, "CommandLink")
119+
add_btn(_("Remove all objects"), self.remove_all, 5, "MessageBoxWarning")
120+
add_btn(_("Close DataLab"), self.close_cdl, 10, "DialogCloseButton")
119121

120122
def add_additional_buttons(self):
121123
"""Add additional buttons"""
@@ -145,3 +147,6 @@ def add_images(self):
145147
@abc.abstractmethod
146148
def remove_all(self):
147149
"""Remove all objects from DataLab"""
150+
151+
def remove_all(self):
152+
"""Remove all objects from DataLab"""

cdlclient/widgets/connection.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
from qtpy import QtGui as QG
2222
from qtpy import QtWidgets as QW
2323

24+
from cdlclient.config import _
2425
from cdlclient.widgets import datalab_banner
2526

2627

27-
class DataLabConnectionThread(QC.QThread):
28+
class ConnectionThread(QC.QThread):
2829
"""DataLab Connection thread"""
2930

3031
SIG_CONNECTION_OK = QC.Signal()
@@ -54,7 +55,7 @@ class ConnectionDialog(QW.QDialog):
5455
def __init__(self, connect_callback: Callable, parent: QW.QWidget = None) -> None:
5556
super().__init__(parent)
5657
win32_fix_title_bar_background(self)
57-
self.setWindowTitle("Connection to DataLab")
58+
self.setWindowTitle(_("Connection to DataLab"))
5859
self.resize(300, 50)
5960
self.host_label = QW.QLabel()
6061
pixmap = QG.QPixmap()
@@ -66,7 +67,7 @@ def __init__(self, connect_callback: Callable, parent: QW.QWidget = None) -> Non
6667
status = QW.QWidget()
6768
status_layout = QW.QHBoxLayout()
6869
status.setLayout(status_layout)
69-
self.status_label = QW.QLabel("Waiting for connection...")
70+
self.status_label = QW.QLabel(_("Waiting for connection..."))
7071
self.status_icon = QW.QLabel()
7172
status_layout.addWidget(self.status_icon)
7273
status_layout.addWidget(self.status_label)
@@ -77,7 +78,7 @@ def __init__(self, connect_callback: Callable, parent: QW.QWidget = None) -> Non
7778
layout.addWidget(self.progress_bar)
7879
layout.addWidget(status)
7980
self.setLayout(layout)
80-
self.thread = DataLabConnectionThread(connect_callback)
81+
self.thread = ConnectionThread(connect_callback)
8182
self.thread.SIG_CONNECTION_OK.connect(self.on_connection_successful)
8283
self.thread.SIG_CONNECTION_KO.connect(self.on_connection_failed)
8384
button_box = QW.QDialogButtonBox(QW.QDialogButtonBox.Cancel)
@@ -97,23 +98,23 @@ def connect_to_server(self) -> None:
9798
"""Connect to server"""
9899
self.progress_bar.setRange(0, 0)
99100
self.set_status_icon("BrowserReload")
100-
self.status_label.setText("Connecting to server...")
101+
self.status_label.setText(_("Connecting to server..."))
101102
self.thread.start()
102103

103104
def on_connection_successful(self) -> None:
104105
"""Connection successful"""
105106
self.progress_bar.setRange(0, 1)
106107
self.progress_bar.setValue(1)
107108
self.set_status_icon("DialogApplyButton")
108-
self.status_label.setText("Connection successful!")
109+
self.status_label.setText(_("Connection successful!"))
109110
QC.QTimer.singleShot(1000, self.accept)
110111

111112
def on_connection_failed(self) -> None:
112113
"""Connection failed"""
113114
self.progress_bar.setRange(0, 1)
114115
self.progress_bar.setValue(1)
115116
self.set_status_icon("MessageBoxCritical")
116-
self.status_label.setText("Connection failed.")
117+
self.status_label.setText(_("Connection failed."))
117118
QC.QTimer.singleShot(2000, self.reject)
118119

119120

0 commit comments

Comments
 (0)