diff --git a/.gitignore b/.gitignore index 9b7ec9a..1b55d6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build/ .kdev4/ POD7.kdev4 +Resources/Lokalize/main.lqa +Resources/Lokalize/fr/POD7.mo diff --git a/Resources/Lokalize/0_getstrings.sh b/Resources/Lokalize/0_getstrings.sh new file mode 100755 index 0000000..7e28cef --- /dev/null +++ b/Resources/Lokalize/0_getstrings.sh @@ -0,0 +1,19 @@ +#!/bin/bash +if [ ! -x 0_getstrings.sh ] +then + echo "Wrong working directory. Please cd to the directory containing this script." + exit 0 +fi + +APPNAME=POD7 +SRC=../../ +DOMAIN=fr +DEST=$DOMAIN/$APPNAME.po +[ ! -d $DOMAIN ] && mkdir $DOMAIN +[ -f $DEST ] && JOIN="-j" +[ -f $DEST ] && cp $DEST $DEST.bak-$(date +%F-%T) + +xgettext --keyword=_ -d $DOMAIN $JOIN -o $DEST --c++ --from-code=UTF-8 $(find $SRC -maxdepth 1 -type f -name "*.cpp") +#xgettext --keyword=_ -d $DOMAIN -j -o $DEST --c++ --from-code=UTF-8 $(find $SRC -maxdepth 1 -type f -name "*.h") + +exit 0 diff --git a/Resources/Lokalize/2_makemo.sh b/Resources/Lokalize/2_makemo.sh new file mode 100755 index 0000000..2ab04f6 --- /dev/null +++ b/Resources/Lokalize/2_makemo.sh @@ -0,0 +1,16 @@ +#!/bin/bash +if [ ! -x 2_makemo.sh ] +then + echo "Wrong working directory. Please cd to the directory containing this script." + exit 0 +fi + +APPNAME=POD7 +DOMAIN=fr + +msgfmt $DOMAIN/$APPNAME.po -o $DOMAIN/$APPNAME.mo + +# cp $DOMAIN/$APPNAME.mo /usr/local/share/locale/$DOMAIN/LC_MESSAGES/ + +exit 0 + diff --git a/Resources/Lokalize/fr/POD7.po b/Resources/Lokalize/fr/POD7.po new file mode 100644 index 0000000..b5039d2 --- /dev/null +++ b/Resources/Lokalize/fr/POD7.po @@ -0,0 +1,55 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Saleem EDAH-TALLY , 2022. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-10-16 16:17+0200\n" +"PO-Revision-Date: 2022-10-16 16:22+0200\n" +"Last-Translator: Saleem EDAH-TALLY \n" +"Language-Team: French <>\n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Lokalize 22.08.2\n" + +#: ../../main.cpp:49 ../../main.cpp:157 +msgid "Can't initialize HID library." +msgstr "Ne peut initialiser la bibliothèque HID." + +#: ../../main.cpp:57 +msgid "No hidraw devices found." +msgstr "Aucun périphérique hidraw détecté." + +#: ../../main.cpp:94 +msgid "Print help messages." +msgstr "Afficher l'aide." + +#: ../../main.cpp:102 +msgid "hidraw pedal device file (/dev/)." +msgstr "Périphérique hidraw détecté (/dev/)." + +#: ../../main.cpp:104 +msgid "Show some messages on stdout, namely, signaled pedal codes." +msgstr "" +"Affichage plus verbeux, en particulier, des codes emis par les pédales." + +#: ../../main.cpp:129 ../../main.cpp:135 +msgid "Error : " +msgstr "Erreur : " + +#: ../../main.cpp:163 +msgid "Can't open " +msgstr "Ne peur ouvrir " + +#: ../../main.cpp:201 +msgid "Application exit." +msgstr "Fin d'application." + +#: ../../main.cpp:103 +msgid "List hidraw devices." +msgstr "Énumérer les périphériques hidraw." diff --git a/Resources/Lokalize/index.lokalize b/Resources/Lokalize/index.lokalize new file mode 100644 index 0000000..e2d1628 --- /dev/null +++ b/Resources/Lokalize/index.lokalize @@ -0,0 +1,5 @@ +[General] +LangCode=fr_FR +MailingList= +ProjectID=POD7-Lokalize +TargetLangCode=fr_FR diff --git a/globals.h b/globals.h index 811de27..382c158 100644 --- a/globals.h +++ b/globals.h @@ -9,6 +9,14 @@ #ifndef GLOBALS_H #define GLOBALS_H +#include +#include +using namespace std; + +//https://www.labri.fr/perso/fleury/posts/programming/a-quick-gettext-tutorial.html +#define _(STRING) gettext(STRING) + + #define _APPNAME_ "POD7" // Pedal events Over DBus #define _APP_DESCRIPTION_ "Send pedal events over DBus" #define _VERSION_ "2" diff --git a/main.cpp b/main.cpp index f15ebea..d0a1b34 100644 --- a/main.cpp +++ b/main.cpp @@ -32,7 +32,7 @@ DBus::BusDispatcher g_dispatcher; void signalhandler(int sn) { if (g_verbose) - cout << "Application signaled to exit." << endl; + cout << "_(Application signaled to exit.)" << endl; hid_close(g_device); hid_exit(); exit(0); @@ -46,7 +46,7 @@ bool ListDevices() { if (hid_init() != 0) { - cout << "Can't initialize HID library." << endl; + cout << _("Can't initialize HID library.") << endl; return false; } hid_device_info * devices; @@ -54,7 +54,7 @@ bool ListDevices() if (devices == NULL) { if (g_verbose) - cout << "No HIDRaw devices found." << endl; + cout << _("No hidraw devices found.") << endl; } else { @@ -91,7 +91,7 @@ bool ManageParams(int argc, char** argv) { po::options_description desc(_ABOUT_); desc.add_options() - ("help,h", "Print help messages.") + ("help,h", _("Print help messages.")) /* * Use an udev rule to identify the hidraw device : * Ex : @@ -99,9 +99,9 @@ bool ManageParams(int argc, char** argv) * KERNEL=="hidraw[0-9]*", SYMLINK+="hidraw-vec", ATTRS{idVendor}=="05f3", ATTRS{idProduct}=="00ff", MODE="0660", GROUP="transcript" * Using /dev/hidraw-vec better control better control. */ - ("device,d", po::value(&g_deviceFile), "HIDRaw pedal device file (/dev/).") - ("list,l", "List HIDRaw devices.") - ("verbose,v", "Show some messages on stdout, namely, signaled pedal codes."); + ("device,d", po::value(&g_deviceFile), _("hidraw pedal device file (/dev/).")) + ("list,l", _("List hidraw devices.")) + ("verbose,v", _("Show some messages on stdout, namely, signaled pedal codes.")); po::variables_map vm; po::variables_map vmc; @@ -126,13 +126,13 @@ bool ManageParams(int argc, char** argv) } catch (po::error& eb) { - cerr << "Error : " << eb.what() << endl; + cerr << _("Error : ") << eb.what() << endl; return false; } } catch (exception& e) { - cerr << "Error : " << e.what() << endl; + cerr << _("Error : ") << e.what() << endl; return false; } @@ -144,19 +144,23 @@ bool ManageParams(int argc, char** argv) */ int main(int argc, char** argv) { + setlocale (LC_ALL, ""); + bindtextdomain (_APPNAME_, "/usr/local/share/locale"); // containing fr/LC_MESSAGES/ + textdomain (_APPNAME_); + if (!ManageParams(argc, argv)) return 0; signal(SIGINT, signalhandler); signal(SIGTERM, signalhandler); if (hid_init() != 0) { - cout << "Can't initialize HID library." << endl; + cout << _("Can't initialize HID library.") << endl; return 0; } g_device = hid_open_path(g_deviceFile.c_str()); if (!g_device) { - cout << "Can't open " << g_device << _DOT_ << endl; + cout << _("Can't open ") << g_device << _DOT_ << endl; hid_exit(); return 0; } @@ -194,7 +198,7 @@ int main(int argc, char** argv) } if (g_verbose) - cout << "Application exit." << endl; + cout << _("Application exit.") << endl; hid_close(g_device); hid_exit(); return 0;