Added -L option to recoll for forcing language for messages
This commit is contained in:
parent
08fabf6872
commit
ef4888d5ec
@ -172,41 +172,43 @@ extern void qInitImages_recoll();
|
|||||||
|
|
||||||
static const char *thisprog;
|
static const char *thisprog;
|
||||||
|
|
||||||
// ATTENTION A LA COMPATIBILITE AVEC LES OPTIONS DE recollq
|
// BEWARE COMPATIBILITY WITH recollq OPTIONS letters
|
||||||
static int op_flags;
|
static int op_flags;
|
||||||
#define OPT_h 0x4
|
#define OPT_a 0x1
|
||||||
#define OPT_c 0x20
|
#define OPT_c 0x2
|
||||||
#define OPT_q 0x40
|
#define OPT_f 0x4
|
||||||
#define OPT_o 0x80
|
#define OPT_h 0x8
|
||||||
#define OPT_l 0x100
|
#define OPT_L 0x10
|
||||||
#define OPT_f 0x200
|
#define OPT_l 0x20
|
||||||
#define OPT_a 0x400
|
#define OPT_o 0x40
|
||||||
#define OPT_t 0x800
|
#define OPT_q 0x80
|
||||||
#define OPT_v 0x1000
|
#define OPT_t 0x100
|
||||||
|
#define OPT_v 0x200
|
||||||
|
|
||||||
static const char usage [] =
|
static const char usage [] =
|
||||||
"\n"
|
"\n"
|
||||||
"recoll [-h] [-c <configdir>] [-q query]\n"
|
"recoll [-h] [-c <configdir>] [-q query]\n"
|
||||||
" -h : Print help and exit\n"
|
" -h : Print help and exit\n"
|
||||||
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
|
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
|
||||||
" [-o|l|f|a] [-t] -q 'query' : search query to be executed as if entered\n"
|
" -L <lang> : force language for GUI messages (e.g. -L fr)\n"
|
||||||
" into simple search. The default is to interpret the argument as a \n"
|
" [-o|l|f|a] [-t] -q 'query' : search query to be executed as if entered\n"
|
||||||
" query language string (but see modifier options)\n"
|
" into simple search. The default is to interpret the argument as a \n"
|
||||||
" In most cases, the query string should be quoted with single-quotes to\n"
|
" query language string (but see modifier options)\n"
|
||||||
" avoid shell interpretation\n"
|
" In most cases, the query string should be quoted with single-quotes to\n"
|
||||||
" -a : the query will be interpreted as an AND query.\n"
|
" avoid shell interpretation\n"
|
||||||
" -o : the query will be interpreted as an OR query.\n"
|
" -a : the query will be interpreted as an AND query.\n"
|
||||||
" -f : the query will be interpreted as a filename search\n"
|
" -o : the query will be interpreted as an OR query.\n"
|
||||||
" -l : the query will be interpreted as a query language string (default)\n"
|
" -f : the query will be interpreted as a filename search\n"
|
||||||
" -t : terminal display: no gui. Results go to stdout. MUST be given\n"
|
" -l : the query will be interpreted as a query language string (default)\n"
|
||||||
" explicitly as -t (not ie, -at), and -q <query> MUST\n"
|
" -t : terminal display: no gui. Results go to stdout. MUST be given\n"
|
||||||
" be last on the command line if this is used.\n"
|
" explicitly as -t (not ie, -at), and -q <query> MUST\n"
|
||||||
" Use -t -h to see the additional non-gui options\n"
|
" be last on the command line if this is used.\n"
|
||||||
"recoll -v : print version\n"
|
" Use -t -h to see the additional non-gui options\n"
|
||||||
"recoll <url>\n"
|
"recoll -v : print version\n"
|
||||||
" This is used to open a recoll url (including an ipath), and called\n"
|
"recoll <url>\n"
|
||||||
" typically from another search interface like the Unity Dash\n"
|
" This is used to open a recoll url (including an ipath), and called\n"
|
||||||
;
|
" typically from another search interface like the Unity Dash\n"
|
||||||
|
;
|
||||||
static void
|
static void
|
||||||
Usage(void)
|
Usage(void)
|
||||||
{
|
{
|
||||||
@ -235,6 +237,7 @@ int main(int argc, char **argv)
|
|||||||
QCoreApplication::setApplicationName("recoll");
|
QCoreApplication::setApplicationName("recoll");
|
||||||
|
|
||||||
string a_config;
|
string a_config;
|
||||||
|
string a_lang;
|
||||||
string question;
|
string question;
|
||||||
string urltoview;
|
string urltoview;
|
||||||
|
|
||||||
@ -253,6 +256,9 @@ int main(int argc, char **argv)
|
|||||||
argc--; goto b1;
|
argc--; goto b1;
|
||||||
case 'f': op_flags |= OPT_f; break;
|
case 'f': op_flags |= OPT_f; break;
|
||||||
case 'h': op_flags |= OPT_h; Usage();break;
|
case 'h': op_flags |= OPT_h; Usage();break;
|
||||||
|
case 'L': op_flags |= OPT_L; if (argc < 2) Usage();
|
||||||
|
a_lang = *(++argv);
|
||||||
|
argc--; goto b1;
|
||||||
case 'l': op_flags |= OPT_l; break;
|
case 'l': op_flags |= OPT_l; break;
|
||||||
case 'o': op_flags |= OPT_o; break;
|
case 'o': op_flags |= OPT_o; break;
|
||||||
case 'q': op_flags |= OPT_q; if (argc < 2) Usage();
|
case 'q': op_flags |= OPT_q; if (argc < 2) Usage();
|
||||||
@ -298,7 +304,12 @@ int main(int argc, char **argv)
|
|||||||
// fprintf(stderr, "recollinit done\n");
|
// fprintf(stderr, "recollinit done\n");
|
||||||
|
|
||||||
// Translations for Qt standard widgets
|
// Translations for Qt standard widgets
|
||||||
QString slang = QLocale::system().name().left(2);
|
QString slang;
|
||||||
|
if (op_flags & OPT_L) {
|
||||||
|
slang = u8s2qs(a_lang);
|
||||||
|
} else {
|
||||||
|
slang = QLocale::system().name().left(2);
|
||||||
|
}
|
||||||
QTranslator qt_trans(0);
|
QTranslator qt_trans(0);
|
||||||
qt_trans.load(QString("qt_%1").arg(slang),
|
qt_trans.load(QString("qt_%1").arg(slang),
|
||||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
@ -315,7 +326,10 @@ int main(int argc, char **argv)
|
|||||||
string historyfile = path_cat(theconfig->getConfDir(), "history");
|
string historyfile = path_cat(theconfig->getConfDir(), "history");
|
||||||
g_dynconf = new RclDynConf(historyfile);
|
g_dynconf = new RclDynConf(historyfile);
|
||||||
if (!g_dynconf || !g_dynconf->ok()) {
|
if (!g_dynconf || !g_dynconf->ok()) {
|
||||||
QString msg = app.translate("Main", "\"history\" file is damaged or un(read)writeable, please check or remove it: ") + QString::fromLocal8Bit(historyfile.c_str());
|
QString msg = app.translate
|
||||||
|
("Main",
|
||||||
|
"\"history\" file is damaged or un(read)writeable, please check "
|
||||||
|
"or remove it: ") + QString::fromLocal8Bit(historyfile.c_str());
|
||||||
QMessageBox::critical(0, "Recoll", msg);
|
QMessageBox::critical(0, "Recoll", msg);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -343,9 +357,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
string dbdir = theconfig->getDbDir();
|
string dbdir = theconfig->getDbDir();
|
||||||
if (dbdir.empty()) {
|
if (dbdir.empty()) {
|
||||||
QMessageBox::critical(0, "Recoll",
|
QMessageBox::critical(
|
||||||
app.translate("Main",
|
0, "Recoll",
|
||||||
"No db directory in configuration"));
|
app.translate("Main", "No db directory in configuration"));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -137,10 +137,10 @@ Usage(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ATTENTION A LA COMPATIBILITE AVEC LES OPTIONS DE recoll
|
// BEWARE COMPATIBILITy WITH recoll OPTIONS letters
|
||||||
// -q, -t and -l are accepted and ignored
|
// -q, -t and -l are accepted and ignored
|
||||||
// -a/f/o -c have the same meaning
|
// -a/f/o -c have the same meaning
|
||||||
// -h is not used
|
// -h and -v -> Usage()
|
||||||
|
|
||||||
static int op_flags;
|
static int op_flags;
|
||||||
#define OPT_A 0x1
|
#define OPT_A 0x1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user