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;
|
||||
|
||||
// ATTENTION A LA COMPATIBILITE AVEC LES OPTIONS DE recollq
|
||||
// BEWARE COMPATIBILITY WITH recollq OPTIONS letters
|
||||
static int op_flags;
|
||||
#define OPT_h 0x4
|
||||
#define OPT_c 0x20
|
||||
#define OPT_q 0x40
|
||||
#define OPT_o 0x80
|
||||
#define OPT_l 0x100
|
||||
#define OPT_f 0x200
|
||||
#define OPT_a 0x400
|
||||
#define OPT_t 0x800
|
||||
#define OPT_v 0x1000
|
||||
#define OPT_a 0x1
|
||||
#define OPT_c 0x2
|
||||
#define OPT_f 0x4
|
||||
#define OPT_h 0x8
|
||||
#define OPT_L 0x10
|
||||
#define OPT_l 0x20
|
||||
#define OPT_o 0x40
|
||||
#define OPT_q 0x80
|
||||
#define OPT_t 0x100
|
||||
#define OPT_v 0x200
|
||||
|
||||
static const char usage [] =
|
||||
"\n"
|
||||
"recoll [-h] [-c <configdir>] [-q query]\n"
|
||||
" -h : Print help and exit\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"
|
||||
" into simple search. The default is to interpret the argument as a \n"
|
||||
" query language string (but see modifier options)\n"
|
||||
" In most cases, the query string should be quoted with single-quotes to\n"
|
||||
" avoid shell interpretation\n"
|
||||
" -a : the query will be interpreted as an AND query.\n"
|
||||
" -o : the query will be interpreted as an OR query.\n"
|
||||
" -f : the query will be interpreted as a filename search\n"
|
||||
" -l : the query will be interpreted as a query language string (default)\n"
|
||||
" -t : terminal display: no gui. Results go to stdout. MUST be given\n"
|
||||
" explicitly as -t (not ie, -at), and -q <query> MUST\n"
|
||||
" be last on the command line if this is used.\n"
|
||||
" Use -t -h to see the additional non-gui options\n"
|
||||
"recoll -v : print version\n"
|
||||
"recoll <url>\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"
|
||||
;
|
||||
"\n"
|
||||
"recoll [-h] [-c <configdir>] [-q query]\n"
|
||||
" -h : Print help and exit\n"
|
||||
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
|
||||
" -L <lang> : force language for GUI messages (e.g. -L fr)\n"
|
||||
" [-o|l|f|a] [-t] -q 'query' : search query to be executed as if entered\n"
|
||||
" into simple search. The default is to interpret the argument as a \n"
|
||||
" query language string (but see modifier options)\n"
|
||||
" In most cases, the query string should be quoted with single-quotes to\n"
|
||||
" avoid shell interpretation\n"
|
||||
" -a : the query will be interpreted as an AND query.\n"
|
||||
" -o : the query will be interpreted as an OR query.\n"
|
||||
" -f : the query will be interpreted as a filename search\n"
|
||||
" -l : the query will be interpreted as a query language string (default)\n"
|
||||
" -t : terminal display: no gui. Results go to stdout. MUST be given\n"
|
||||
" explicitly as -t (not ie, -at), and -q <query> MUST\n"
|
||||
" be last on the command line if this is used.\n"
|
||||
" Use -t -h to see the additional non-gui options\n"
|
||||
"recoll -v : print version\n"
|
||||
"recoll <url>\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
|
||||
Usage(void)
|
||||
{
|
||||
@ -235,6 +237,7 @@ int main(int argc, char **argv)
|
||||
QCoreApplication::setApplicationName("recoll");
|
||||
|
||||
string a_config;
|
||||
string a_lang;
|
||||
string question;
|
||||
string urltoview;
|
||||
|
||||
@ -253,6 +256,9 @@ int main(int argc, char **argv)
|
||||
argc--; goto b1;
|
||||
case 'f': op_flags |= OPT_f; 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 'o': op_flags |= OPT_o; break;
|
||||
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");
|
||||
|
||||
// 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);
|
||||
qt_trans.load(QString("qt_%1").arg(slang),
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
@ -315,7 +326,10 @@ int main(int argc, char **argv)
|
||||
string historyfile = path_cat(theconfig->getConfDir(), "history");
|
||||
g_dynconf = new RclDynConf(historyfile);
|
||||
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);
|
||||
exit(1);
|
||||
}
|
||||
@ -343,9 +357,9 @@ int main(int argc, char **argv)
|
||||
|
||||
string dbdir = theconfig->getDbDir();
|
||||
if (dbdir.empty()) {
|
||||
QMessageBox::critical(0, "Recoll",
|
||||
app.translate("Main",
|
||||
"No db directory in configuration"));
|
||||
QMessageBox::critical(
|
||||
0, "Recoll",
|
||||
app.translate("Main", "No db directory in configuration"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@ -137,10 +137,10 @@ Usage(void)
|
||||
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
|
||||
// -a/f/o -c have the same meaning
|
||||
// -h is not used
|
||||
// -h and -v -> Usage()
|
||||
|
||||
static int op_flags;
|
||||
#define OPT_A 0x1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user