Add localization resources.

This commit is contained in:
SET
2022-10-16 15:42:36 +02:00
parent 8afc503891
commit 22ef6788de
8 changed files with 205 additions and 27 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,6 @@
build/
.kdev4
saf7.kdev4
Resources/Lokalize/main.lqa
Resources/Lokalize/*/saf7.mo

View File

@@ -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=saf7
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

16
Resources/Lokalize/2_makemo.sh Executable file
View File

@@ -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=saf7
DOMAIN=fr
msgfmt $DOMAIN/$APPNAME.po -o $DOMAIN/$APPNAME.mo
# cp $DOMAIN/$APPNAME.mo /usr/local/share/locale/$DOMAIN/LC_MESSAGES/
exit 0

View File

@@ -0,0 +1,129 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Saleem EDAH-TALLY <set@nmset.info>, 2022.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-10-16 12:34+0200\n"
"PO-Revision-Date: 2022-10-16 12:55+0200\n"
"Last-Translator: Saleem EDAH-TALLY <set@nmset.info>\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"
#: ../../SAF.cpp:58
msgid "Connected ("
msgstr "Connecté ("
#: ../../SAF.cpp:65
msgid "Disconnected ("
msgstr "Déconnecté ("
#: ../../SAF.cpp:114
msgid "Cannot initiate a connection. Check network, server, or parameters."
msgstr ""
"Ne peut initialiser une connexion. Vérifiez le réseau, le serveur ou les"
" paramètres."
#: ../../SAF.cpp:119
msgid "Try "
msgstr "Essai"
#: ../../SAF.cpp:120
msgid " : Waiting "
msgstr " : Attente"
#: ../../SAF.cpp:121
msgid " before connecting..."
msgstr " avant reconnexion"
#: ../../SAF.cpp:127
msgid "Giving up."
msgstr "Abandon."
#: ../../main.cpp:68
msgid "Signaled to exit."
msgstr "Signal d'arrêt."
#: ../../main.cpp:79
msgid "Full JID without resource"
msgstr "JID complet sans la partie 'resource'"
#: ../../main.cpp:80
msgid "Password"
msgstr "Mot de passe"
#: ../../main.cpp:81
msgid "Resource (optional)"
msgstr "Resource (optionnel)"
#: ../../main.cpp:82
msgid "Server (optional)"
msgstr "Serveur (optionnel)"
#: ../../main.cpp:83
msgid "Port (optional), default = 5222"
msgstr "Port (optionnel), par défaut : 5222"
#: ../../main.cpp:84
msgid ""
"Number of times to try to connect to server (optional), default = 0 (for "
"ever)"
msgstr ""
"Nombre de tentative de reconnexion au serveur (optionnel), par défaut : 0"
" (tentatives permanentes)"
#: ../../main.cpp:85
msgid ""
"Number of seconds between each connection attempt (optional), default = 30"
msgstr "Délai entre les tentatives de connexion (optionnel), par défaut : 30"
#: ../../main.cpp:86
msgid ""
"Number of seconds between each whitespace ping to the server (optional), "
"default = 0 (never), at least 55"
msgstr ""
"Délai entre les pings de maintien de connexion au serveur (optionnel), par"
" défaut : 0 (jamais), au moins 55"
#: ../../main.cpp:87
msgid "Bus name tag (optional), default=default"
msgstr "Étiquette du bus (optionnel), défaut : default"
#: ../../main.cpp:88
msgid ""
"Use specified configuration file (optional), else, pass all parameters on "
"the command line"
msgstr ""
"Utiliser un fichier de configuration (optionnel), ou fournir tous les"
" paramètres à la ligne de commande"
#: ../../main.cpp:89
msgid "Show messages (optional). Command line only."
msgstr "Sortie verbeuse (optionnel). Ligne de commande uniquement."
#: ../../main.cpp:115
msgid "Failure with file : "
msgstr "Échec avec le fichier :"
#: ../../main.cpp:124 ../../main.cpp:130
msgid "Error : "
msgstr "Erreur :"
#: ../../main.cpp:136
msgid "jid missing."
msgstr "jid manquant."
#: ../../main.cpp:141
msgid "password missing."
msgstr "Mot de passe manquant."
#: ../../main.cpp:146
msgid "wsping must be at least 55 seconds."
msgstr "wsping doit être au moins 55 secondes."

View File

@@ -0,0 +1,5 @@
[General]
LangCode=fr_FR
MailingList=
ProjectID=saf7-Lokalize
TargetLangCode=fr_FR

16
SAF.cpp
View File

@@ -55,14 +55,14 @@ void SAFConnListener::onConnect()
m_lastError = ConnectionError::ConnNoError;
m_connector->ResetCounter();
if (g_verbose)
cout << "Connected (" << m_client->jid().bare() << ")." << endl;
cout << _("Connected (") << m_client->jid().bare() << ")." << endl;
}
void SAFConnListener::onDisconnect(ConnectionError e)
{
m_lastError = e;
if (g_verbose)
cout << "Disconnected (" << m_client->jid().bare() << ")." << endl;
cout << _("Disconnected (") << m_client->jid().bare() << ")." << endl;
if (e == ConnNoError || e == ConnUserDisconnected) return;
cout << ConnErrorMap[e] << endl;
}
@@ -111,20 +111,20 @@ void Connector::DoConnect()
*/
&& m_saf->GetLastError() != ConnectionError::ConnConnectionRefused)
{
cout << "Cannot initiate a connection."
" Check network, server, or parameters." << endl;
cout << _("Cannot initiate a connection."
" Check network, server, or parameters.") << endl;
break;
}
if (g_verbose)
cout << "Try " << m_count
<< " : Waiting " << m_delay << " seconds"
<< " before connecting..." << endl;
cout << _("Try ") << m_count
<< _(" : Waiting ") << m_delay << " seconds"
<< _(" before connecting...") << endl;
sleep(m_delay);
m_count++;
if (m_retry > 0 && m_count == m_retry)
{
if (g_verbose)
cout << "Giving up." << endl;
cout << _("Giving up.") << endl;
break;
}
}

View File

@@ -10,9 +10,13 @@
#ifndef GLOBALS_H
#define GLOBALS_H
#include <libintl.h>
#include <string>
using namespace std;
//https://www.labri.fr/perso/fleury/posts/programming/a-quick-gettext-tutorial.html
#define _(STRING) gettext(STRING)
#define _APPNAME_ "saf7" // Send and forget
#define _APP_DESCRIPTION_ "Send and forget an XMPP message"
#define _VERSION_ "5"

View File

@@ -65,7 +65,7 @@ void signalhandler(int sn)
delete g_client;
delete g_saf;
if (g_verbose)
cout << "Signaled to exit." << endl;
cout << _("Signaled to exit.") << endl;
exit(0);
}
@@ -76,17 +76,17 @@ bool GetAndValidateParams(int argc, char** argv)
po::options_description desc(_ABOUT_);
desc.add_options()
("help,h", "Print help messages")
("jid,j", po::value<string>(&g_jid), "Full JID without resource")
("password,w", po::value<string>(&g_password), "Password")
("resource,r", po::value<string>(&g_resource), "Resource (optional)")
("server,s", po::value<string>(&g_server), "Server (optional)")
("port,p", po::value<uint>(&g_port), "Port (optional), default = 5222")
("retry,y", po::value<uint>(&g_retry), "Number of times to try to connect to server (optional), default = 0 (for ever)")
("delay,d", po::value<uint>(&g_delay), "Number of seconds between each connection attempt (optional), default = 30")
("wsping,g", po::value<uint>(&g_wsping), "Number of seconds between each whitespace ping to the server (optional), default = 0 (never), at least 55")
("bustag,t", po::value<string>(&g_tag), "Bus name tag (optional), default=default")
("config,c", po::value<string>(&g_config), "Use specified configuration file (optional), else, pass all parameters on the command line")
("verbose,v", "Show messages (optional). Command line only.");
("jid,j", po::value<string>(&g_jid), _("Full JID without resource"))
("password,w", po::value<string>(&g_password), _("Password"))
("resource,r", po::value<string>(&g_resource), _("Resource (optional)"))
("server,s", po::value<string>(&g_server), _("Server (optional)"))
("port,p", po::value<uint>(&g_port), _("Port (optional), default = 5222"))
("retry,y", po::value<uint>(&g_retry), _("Number of times to try to connect to server (optional), default = 0 (for ever)"))
("delay,d", po::value<uint>(&g_delay), _("Number of seconds between each connection attempt (optional), default = 30"))
("wsping,g", po::value<uint>(&g_wsping), _("Number of seconds between each whitespace ping to the server (optional), default = 0 (never), at least 55"))
("bustag,t", po::value<string>(&g_tag), _("Bus name tag (optional), default=default"))
("config,c", po::value<string>(&g_config), _("Use specified configuration file (optional), else, pass all parameters on the command line"))
("verbose,v", _("Show messages (optional). Command line only."));
po::variables_map vm;
po::variables_map vmc;
@@ -112,7 +112,7 @@ bool GetAndValidateParams(int argc, char** argv)
ifstream f(g_config);
if (f.fail())
{
cerr << "Failure with file : " << g_config << endl;
cerr << _("Failure with file : ") << g_config << endl;
return 0;
}
po::store(po::parse_config_file(f, desc), vmc);
@@ -121,29 +121,29 @@ bool GetAndValidateParams(int argc, char** argv)
}
catch (po::error& eb)
{
cerr << "Error : " << eb.what() << endl;
cerr << _("Error : ") << eb.what() << endl;
return 0;
}
}
catch (exception& e)
{
cerr << "Error : " << e.what() << endl;
cerr << _("Error : ") << e.what() << endl;
return 0;
}
if (g_jid.empty())
{
cout << "jid missing." << endl;
cout << _("jid missing.") << endl;
return 0;
}
if (g_password.empty())
{
cout << "password missing." << endl;
cout << _("password missing.") << endl;
return 0;
}
if (g_wsping > 0 && g_wsping < 55 )
{
cout << "wsping must be at least 55 seconds." << endl;
cout << _("wsping must be at least 55 seconds.") << endl;
return 0;
}
return true;
@@ -167,6 +167,9 @@ DBusSafAdaptor* StartDBusAdaptor(Connector * connector, SAFConnListener * saf)
int main(int argc, char** argv)
{
setlocale (LC_ALL, "");
bindtextdomain (_APPNAME_, "/usr/local/share/locale"); // containing fr/LC_MESSAGES/
textdomain (_APPNAME_);
if (!GetAndValidateParams(argc, argv))
return 0;