mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-05 18:20:33 -08:00
add function QINSTALL-TRANSLATOR to change UI language at runtime
This commit is contained in:
parent
878007b8f2
commit
68afb26ae3
5 changed files with 34 additions and 0 deletions
|
|
@ -182,6 +182,14 @@
|
||||||
(qget *quick-view* |width|)
|
(qget *quick-view* |width|)
|
||||||
|
|
||||||
|
|
||||||
|
<b>qinstall-translator (language)</b>
|
||||||
|
|
||||||
|
Only needed for changing the UI language at runtime.
|
||||||
|
Returns the passed language string if successful.
|
||||||
|
|
||||||
|
(qinstall-translator "es") ; assumes file 'es.qm' (spanish) is present in 'i18n/'
|
||||||
|
|
||||||
|
|
||||||
<b>qjs (function item/name &rest arguments)</b>
|
<b>qjs (function item/name &rest arguments)</b>
|
||||||
|
|
||||||
Fast and convenient way to call JS functions defined in QML. You may pass
|
Fast and convenient way to call JS functions defined in QML. You may pass
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QTranslator>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtQml/QQmlEngine>
|
#include <QtQml/QQmlEngine>
|
||||||
|
|
@ -47,6 +48,7 @@ void iniCLFunctions() {
|
||||||
DEFUN ("%qfind-children", qfind_children2, 3)
|
DEFUN ("%qfind-children", qfind_children2, 3)
|
||||||
DEFUN ("qfrom-utf8", qfrom_utf8, 1)
|
DEFUN ("qfrom-utf8", qfrom_utf8, 1)
|
||||||
DEFUN ("qto-utf8", qto_utf8, 1)
|
DEFUN ("qto-utf8", qto_utf8, 1)
|
||||||
|
DEFUN ("qinstall-translator", qinstall_translator, 1)
|
||||||
DEFUN ("qinvoke-method", qinvoke_method, 4)
|
DEFUN ("qinvoke-method", qinvoke_method, 4)
|
||||||
DEFUN ("%qload-c++", qload_cpp, 2)
|
DEFUN ("%qload-c++", qload_cpp, 2)
|
||||||
DEFUN ("qload-rc", qload_rc, 1)
|
DEFUN ("qload-rc", qload_rc, 1)
|
||||||
|
|
@ -490,6 +492,27 @@ cl_object qnull(cl_object l_arg) {
|
||||||
ecl_return1(ecl_process_env(), (qobject == nullptr) ? ECL_T : ECL_NIL);
|
ecl_return1(ecl_process_env(), (qobject == nullptr) ? ECL_T : ECL_NIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cl_object qinstall_translator(cl_object l_lang) {
|
||||||
|
/// args: (language)
|
||||||
|
/// Only needed for changing the UI language at runtime.
|
||||||
|
/// Returns the passed language string if successful.
|
||||||
|
/// (qinstall-translator "es") ; assumes file 'es.qm' (spanish) is present in 'i18n/'
|
||||||
|
ecl_process_env()->nvalues = 1;
|
||||||
|
QString lang(toQString(l_lang));
|
||||||
|
if (!lang.isEmpty()) {
|
||||||
|
QTranslator translator;
|
||||||
|
QString trFile(QDir::currentPath() + "/i18n");
|
||||||
|
if ((QFile::exists(trFile) && translator.load(QLocale(lang), QString(), QString(), trFile))
|
||||||
|
|| translator.load(QLocale(lang), QString(), QString(), ":/i18n")) {
|
||||||
|
QCoreApplication::installTranslator(&translator);
|
||||||
|
LQML::quickView->engine()->retranslate();
|
||||||
|
return l_lang;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error_msg("QINSTALL-TRANSLATOR", LIST1(l_lang));
|
||||||
|
return ECL_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
cl_object qinvoke_method(cl_object l_obj, cl_object l_name, cl_object l_args, cl_object l_qjs_call) {
|
cl_object qinvoke_method(cl_object l_obj, cl_object l_name, cl_object l_args, cl_object l_qjs_call) {
|
||||||
// for internal use: this is used to call user defined JS functions, and to
|
// for internal use: this is used to call user defined JS functions, and to
|
||||||
// call user defined Qt/C++ plugin functions.
|
// call user defined Qt/C++ plugin functions.
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ cl_object qfind_child (cl_object, cl_object);
|
||||||
cl_object qfind_children2 (cl_object, cl_object, cl_object);
|
cl_object qfind_children2 (cl_object, cl_object, cl_object);
|
||||||
cl_object qfrom_utf8 (cl_object);
|
cl_object qfrom_utf8 (cl_object);
|
||||||
cl_object qto_utf8 (cl_object);
|
cl_object qto_utf8 (cl_object);
|
||||||
|
cl_object qinstall_translator (cl_object);
|
||||||
cl_object qinvoke_method (cl_object, cl_object, cl_object, cl_object);
|
cl_object qinvoke_method (cl_object, cl_object, cl_object, cl_object);
|
||||||
cl_object qload_cpp (cl_object, cl_object);
|
cl_object qload_cpp (cl_object, cl_object);
|
||||||
cl_object qload_rc (cl_object);
|
cl_object qload_rc (cl_object);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
(defun qfind-child (a b))
|
(defun qfind-child (a b))
|
||||||
(defun %qfind-children (a b c))
|
(defun %qfind-children (a b c))
|
||||||
(defun qfrom-utf8 (a))
|
(defun qfrom-utf8 (a))
|
||||||
|
(defun qinstall-translator (a))
|
||||||
(defun qinvoke-method (a b c d))
|
(defun qinvoke-method (a b c d))
|
||||||
(defun %qload-c++ (a b))
|
(defun %qload-c++ (a b))
|
||||||
(defun %qlog (a))
|
(defun %qlog (a))
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#:qexit
|
#:qexit
|
||||||
#:qfrom-utf8
|
#:qfrom-utf8
|
||||||
#:qget
|
#:qget
|
||||||
|
#:qinstall-translator
|
||||||
#:qset
|
#:qset
|
||||||
#:qlater
|
#:qlater
|
||||||
#:qlater-sequence
|
#:qlater-sequence
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue