aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/language/libkvilanguage.cpp
diff options
context:
space:
mode:
authorGravatar Fabio Bas2008-05-10 23:51:35 +0000
committerGravatar Fabio Bas2008-05-10 23:51:35 +0000
commit4439e311c33b480ffaad2b0385bc23611fa90482 (patch)
treec832df12e8c211a25a6b89872c91c7cfca52e70d /src/modules/language/libkvilanguage.cpp
parentQuick fix for missing include in KDE compilation (diff)
downloadKVIrc-4439e311c33b480ffaad2b0385bc23611fa90482.tar.gz
KVIrc-4439e311c33b480ffaad2b0385bc23611fa90482.tar.bz2
KVIrc-4439e311c33b480ffaad2b0385bc23611fa90482.zip
re-activated language module and started implementing its functions
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1743 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/language/libkvilanguage.cpp')
-rw-r--r--src/modules/language/libkvilanguage.cpp63
1 files changed, 54 insertions, 9 deletions
diff --git a/src/modules/language/libkvilanguage.cpp b/src/modules/language/libkvilanguage.cpp
index c7ce80a9c..c2fe14a64 100644
--- a/src/modules/language/libkvilanguage.cpp
+++ b/src/modules/language/libkvilanguage.cpp
@@ -24,19 +24,64 @@
#include "kvi_module.h"
#include "kvi_app.h"
+#include "kvi_locale.h"
+#include <QFileInfo>
+
+#include "langdetector.h"
+
+/*
+ @doc: language.detect
+ @type:
+ command
+ @title:
+ language.detect
+ @short:
+ (Tries to) detect the language and encoding of a text file
+ @syntax:
+ language.detect [document: string]
+ @description:
+ Tries to detect the language and encoding of the file specified
+ as [document]. The file has to be preferably a simple text file,
+ or the detector can be deceived by the file format (eg. html files
+ contains english words inside html tags).
+ [document] can be an absolute path.
+ This command is exported by the "language" module.
+*/
+
+
+static bool language_kvs_cmd_detect(KviKvsModuleCommandCall * c)
+{
+ QString doc;
+
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL,doc)
+ KVSM_PARAMETERS_END(c)
+
+ if(doc.isEmpty()){
+ c->warning(__tr2qs("No file given, no detection occured."));
+ return true;
+ }
+
+ QFileInfo * f= new QFileInfo(doc);
+ qDebug("Path %s",doc.toUtf8().data());
+ if(f)
+ {
+ if(!f->exists())
+ {
+ c->warning(__tr2qs("The file you specified doesn't exists, can't detect its language."));
+ return true;
+ }
+ }
+
+ KviLangDetetector *w = new KviLangDetetector(doc);
+
+ return true;
+}
static bool language_module_init(KviModule * m)
{
- /*
- m->registerFunction("nick",my_module_fnc_nick);
- m->registerFunction("user",my_module_fnc_user);
- m->registerFunction("host",my_module_fnc_host);
- m->registerFunction("ip",my_module_fnc_ip);
- m->registerFunction("server",my_module_fnc_server);
- m->registerFunction("network",my_module_fnc_network);
- m->registerFunction("umode",my_module_fnc_umode);
- */
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"detect",language_kvs_cmd_detect);
return true;
}