mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
add i18n (requires installation from scratch of all existing examples)
This commit is contained in:
parent
ee69ed7c32
commit
b4f2700ddc
16 changed files with 98 additions and 11 deletions
|
|
@ -88,3 +88,8 @@ system(ecl -shell qml/.create-qml-loaders.lisp)
|
|||
|
||||
RESOURCES += $$files(qml/*)
|
||||
RESOURCES += $$files(qml/.ext/*)
|
||||
RESOURCES += $$files(i18n/*.qm)
|
||||
|
||||
lupdate_only {
|
||||
SOURCES += i18n/tr.h
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@
|
|||
(dolist (file (list "package" "x" "ecl-ext" "ini" "qml")) ; load LQML symbols
|
||||
(load (merge-pathnames file "src/lisp/")))
|
||||
|
||||
(progn
|
||||
(defvar cl-user::*tr-path* (truename (cc *current* "i18n/")))
|
||||
(load "src/lisp/tr"))
|
||||
|
||||
#-mobile
|
||||
(progn
|
||||
(require :ecl-curl)
|
||||
|
|
|
|||
|
|
@ -65,4 +65,9 @@ LIBS += -llqml -llisp -Ltmp -lapp
|
|||
HEADERS += ../../src/cpp/main.h
|
||||
SOURCES += ../../src/cpp/main.cpp
|
||||
|
||||
RESOURCES = $$files(qml/*)
|
||||
RESOURCES += $$files(qml/*)
|
||||
RESOURCES += $$files(i18n/*.qm)
|
||||
|
||||
lupdate_only {
|
||||
SOURCES += i18n/tr.h
|
||||
}
|
||||
|
|
|
|||
30
examples/app-template/i18n/readme.md
Normal file
30
examples/app-template/i18n/readme.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
Translations
|
||||
------------
|
||||
|
||||
Wrap all strings which need to be translated in either `(tr "")` (Lisp files)
|
||||
or `qsTr("")` (QML files).
|
||||
|
||||
* compile app (either desktop or mobile), this will generate a dummy file
|
||||
`tr.h`, containing all Lisp strings to translate
|
||||
|
||||
* run Qt command `lupdate` (here: Spanish, Frensh) for creating the translation
|
||||
source files from both Lisp and QML strings:
|
||||
```
|
||||
lupdate ../app.pro -ts es.ts fr.ts
|
||||
```
|
||||
* translate all `*.ts` files using **Qt Linguist**
|
||||
|
||||
* run Qt command `lrelease` to create compiled translation files:
|
||||
```
|
||||
lrelease es.ts fr.ts
|
||||
```
|
||||
* run respective `qmake` again (destop/mobile) in order to include all `*.qm`
|
||||
files (compiled translations)
|
||||
|
||||
* next time you compile the app, the translation files will be included as
|
||||
resources in the executable
|
||||
|
||||
Now when you launch the app, the translation file matching your system locale
|
||||
setting of your platform (see `QLocale`) will be loaded, see
|
||||
[main.cpp](`../../../src/cpp/main.cpp`) in sources.
|
||||
|
|
@ -30,6 +30,10 @@
|
|||
(defun cc (&rest args)
|
||||
(apply 'concatenate 'string args))
|
||||
|
||||
(progn
|
||||
(defvar cl-user::*tr-path* (truename (cc *current* "i18n/")))
|
||||
(load "src/lisp/tr"))
|
||||
|
||||
#-mobile
|
||||
(asdf:make-build "app"
|
||||
:monolithic t
|
||||
|
|
|
|||
|
|
@ -86,4 +86,9 @@ LIBS += -llqml -llisp -Ltmp -lapp
|
|||
HEADERS += ../../src/cpp/main.h cpp/qt.h
|
||||
SOURCES += ../../src/cpp/main.cpp cpp/qt.cpp
|
||||
|
||||
RESOURCES = $$files(qml/*)
|
||||
RESOURCES += $$files(qml/*)
|
||||
RESOURCES += $$files(i18n/*.qm)
|
||||
|
||||
lupdate_only {
|
||||
SOURCES += i18n/tr.h
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@
|
|||
(dolist (file (list "package" "x" "ecl-ext" "ini" "qml")) ; load LQML symbols
|
||||
(load (merge-pathnames file "src/lisp/")))
|
||||
|
||||
(progn
|
||||
(defvar cl-user::*tr-path* (truename (cc *current* "i18n/")))
|
||||
(load "src/lisp/tr"))
|
||||
|
||||
#-mobile
|
||||
(progn
|
||||
(require :ecl-curl)
|
||||
|
|
|
|||
|
|
@ -83,3 +83,8 @@ HEADERS += ../../src/cpp/main.h
|
|||
SOURCES += ../../src/cpp/main.cpp
|
||||
|
||||
RESOURCES += $$files(qml/*)
|
||||
RESOURCES += $$files(i18n/*.qm)
|
||||
|
||||
lupdate_only {
|
||||
SOURCES += i18n/tr.h
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,10 @@
|
|||
(dolist (file (list "package" "x" "ecl-ext" "ini" "qml")) ; load LQML symbols
|
||||
(load (merge-pathnames file "src/lisp/")))
|
||||
|
||||
(progn
|
||||
(defvar cl-user::*tr-path* (truename (cc *current* "i18n/")))
|
||||
(load "src/lisp/tr"))
|
||||
|
||||
#-mobile
|
||||
(progn
|
||||
(require :ecl-curl)
|
||||
|
|
|
|||
|
|
@ -84,4 +84,9 @@ LIBS += -llqml -llisp -Ltmp -lapp
|
|||
HEADERS += ../../src/cpp/main.h
|
||||
SOURCES += ../../src/cpp/main.cpp
|
||||
|
||||
RESOURCES = $$files(qml/*)
|
||||
RESOURCES += $$files(qml/*)
|
||||
RESOURCES += $$files(i18n/*.qm)
|
||||
|
||||
lupdate_only {
|
||||
SOURCES += i18n/tr.h
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@
|
|||
(dolist (file (list "package" "x" "ecl-ext" "ini" "qml")) ; load LQML symbols
|
||||
(load (merge-pathnames file "src/lisp/")))
|
||||
|
||||
(progn
|
||||
(defvar cl-user::*tr-path* (truename (cc *current* "i18n/")))
|
||||
(load "src/lisp/tr"))
|
||||
|
||||
#-mobile
|
||||
(progn
|
||||
(require :ecl-curl)
|
||||
|
|
|
|||
|
|
@ -68,4 +68,9 @@ LIBS += -llqml -llisp -Ltmp -lapp
|
|||
HEADERS += ../../src/cpp/main.h
|
||||
SOURCES += ../../src/cpp/main.cpp
|
||||
|
||||
RESOURCES = $$files(qml/*)
|
||||
RESOURCES += $$files(qml/*)
|
||||
RESOURCES += $$files(i18n/*.qm)
|
||||
|
||||
lupdate_only {
|
||||
SOURCES += i18n/tr.h
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@
|
|||
|
||||
;;(setf c::*compile-print* t) ; for debugging compile errors
|
||||
|
||||
(load (merge-pathnames "src/lisp/tr.lisp")) ; i18n
|
||||
|
||||
;;; --- HACK begin ---
|
||||
|
||||
(in-package :asdf/lisp-action)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QQuickView>
|
||||
#include <QDebug>
|
||||
|
||||
const char LQML::version[] = "22.4.3"; // Apr 2022
|
||||
const char LQML::version[] = "22.5.1"; // May 2022
|
||||
|
||||
extern "C" void ini_LQML(cl_object);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QQmlEngine>
|
||||
#include <QQmlFileSelector>
|
||||
#include <QQuickView>
|
||||
#include <QTranslator>
|
||||
#include <QtDebug>
|
||||
#include <iostream>
|
||||
|
||||
|
|
@ -95,6 +96,11 @@ int main(int argc, char* argv[]) {
|
|||
exit(0);
|
||||
}
|
||||
|
||||
QTranslator translator;
|
||||
if (translator.load(QLocale(), QString(), QString(), ":/i18n")) {
|
||||
QCoreApplication::installTranslator(&translator);
|
||||
}
|
||||
|
||||
new QQmlFileSelector(view.engine(), &view);
|
||||
QString qml("qml/main.qml");
|
||||
QUrl url;
|
||||
|
|
|
|||
|
|
@ -5,16 +5,19 @@
|
|||
|
||||
(defparameter *sources* (make-hash-table :test 'equal))
|
||||
|
||||
(progn
|
||||
(when (probe-file "tr.h")
|
||||
(delete-file "tr.h"))
|
||||
(defvar cl-user::*tr-path* *default-pathname-defaults*)
|
||||
|
||||
(let ((tr.h (merge-pathnames "tr.h" cl-user::*tr-path*)))
|
||||
(when (probe-file tr.h)
|
||||
(delete-file tr.h))
|
||||
(format t "~&creating ~S~%" tr.h)
|
||||
(define-compiler-macro tr (&whole form src &optional con (n -1))
|
||||
(let* ((source (ignore-errors (eval src)))
|
||||
(context* (ignore-errors (eval con)))
|
||||
(context (if (stringp context*)
|
||||
context*
|
||||
(file-namestring *compile-file-truename*))))
|
||||
(with-open-file (out "tr.h" :direction :output :if-exists :append :if-does-not-exist :create)
|
||||
(with-open-file (out tr.h :direction :output :if-exists :append :if-does-not-exist :create)
|
||||
(if (stringp source)
|
||||
(unless (gethash (cons source context) *sources*)
|
||||
(setf (gethash (cons source context) *sources*) t)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue