diff --git a/i18n/pix_en.ts b/i18n/pix_en.ts
new file mode 100644
index 0000000..f1c0645
--- /dev/null
+++ b/i18n/pix_en.ts
@@ -0,0 +1,20 @@
+
+
+
+
+ QAction
+
+
+
+ Quit
+
+
+
+ QMenu
+
+
+
+ File
+
+
+
diff --git a/i18n/pix_fr.ts b/i18n/pix_fr.ts
new file mode 100644
index 0000000..78ce21c
--- /dev/null
+++ b/i18n/pix_fr.ts
@@ -0,0 +1,20 @@
+
+
+
+
+ QAction
+
+
+
+ Quitter
+
+
+
+ QMenu
+
+
+
+ Fichier
+
+
+
diff --git a/meson.build b/meson.build
index f635e7c..5e7668e 100644
--- a/meson.build
+++ b/meson.build
@@ -8,8 +8,11 @@ project(
]
)
+data_dir = get_option('prefix') / get_option('datadir') / 'pixtool'
+
conf = configuration_data()
conf.set('version', meson.project_version())
+conf.set('datadir', data_dir)
configure_file(
input: 'src/conf.in.hpp',
@@ -26,6 +29,15 @@ qt_src = qt6.compile_moc(
]
)
+translations = qt6.compile_translations(
+ ts_files: [
+ 'i18n/pix_en.ts',
+ 'i18n/pix_fr.ts'
+ ],
+ install: true,
+ install_dir: data_dir / 'i18n'
+)
+
pixtool = static_library(
'pixtool-core',
sources: [
@@ -41,7 +53,7 @@ pixtool = static_library(
# gui
'src/gui/Window.cpp',
- ] + qt_src,
+ ] + qt_src + translations,
dependencies: [
qt6_dep,
dependency('spdlog')
diff --git a/src/conf.in.hpp b/src/conf.in.hpp
index cedf6fa..615f4c3 100644
--- a/src/conf.in.hpp
+++ b/src/conf.in.hpp
@@ -1,6 +1,8 @@
#ifndef pt_CONF_HPP
#define pt_CONF_HPP
+#include
#define PT_VERSION std::string("@version@")
+#define PT_DATADIR std::filesystem::path("@datadir@")
#endif
diff --git a/src/gui/Window.cpp b/src/gui/Window.cpp
index dec03f1..0f3c5c8 100644
--- a/src/gui/Window.cpp
+++ b/src/gui/Window.cpp
@@ -19,10 +19,10 @@ namespace pt
QMenuBar* bar = new QMenuBar {this};
- QMenu* file = new QMenu {"File"};
+ QMenu* file = new QMenu {QMenu::tr("file")};
bar->addMenu(file);
- QAction* quit = new QAction {"Quit"};
+ QAction* quit = new QAction {QAction::tr("quit")};
file->addAction(quit);
connect(quit, &QAction::triggered, [this](){
diff --git a/src/main.cpp b/src/main.cpp
index 3427cf7..7bef5a2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,7 @@
#include
#include
+#include
+
#include "model/PixTool.hpp"
#include "gui/Window.hpp"
#include "Presenter.hpp"
@@ -9,8 +11,13 @@ int main(int argc, char** argv)
{
spdlog::set_level(spdlog::level::debug);
+
QApplication app {argc, argv};
+ QTranslator translator;
+ Q_UNUSED(translator.load(QString::fromStdString(PT_DATADIR / "i18n" / "pix_fr.qm")));
+ app.installTranslator(&translator);
+
pt::gui::Window window;
pt::model::PixTool pixtool;