:qt and :qt-impl packages to prevent collision with :cl symbols and fix object with non smoke parent.
Annotate for file src/i18n.lisp
2009-06-11 tobias 1 (in-package :cl-smoke.qt-impl)
2010-01-10 tobias 2
2009-06-11 tobias 3 (defun qt:tr (message &optional context)
2010-01-10 tobias 4 "Returns the translated MESSAGE for CONTEXT or
08:52:49 ' 5 a string STRING-EQUAL to MESSAGE when no translation was found.
' 6
' 7 Translations can be loaded with WITH-TRANSLATOR."
' 8 (qt:core-application.translate (or context "") message))
' 9
' 10 (defmacro with-installed-translator (translator &body body)
' 11 `(unwind-protect
' 12 (progn
' 13 (cxx:install-translator (qt:app) ,translator)
' 14 ,@body)
' 15 (cxx:remove-translator (qt:app) ,translator)))
' 16
2009-06-11 tobias 17 (defmacro qt:with-translator ((base-name &rest paths) &body body)
2010-01-10 tobias 18 "Loads the translations in the BASE-NAME_LANGCODE.qm file;
08:52:49 ' 19 searching PATHS.
' 20
' 21 Must be in a WITH-APP."
' 22 (let ((translator (gensym)))
2009-06-11 tobias 23 `(let ((,translator (make-instance 'qt:translator)))
2010-01-10 tobias 24 (unless
08:52:49 ' 25 (find-if #'(lambda (path)
' 26 (cxx:load ,translator
' 27 (format nil "~A_~A" ,base-name
' 28 (cxx:name (qt:locale.system)))
' 29 (namestring path)))
' 30 (list ,@paths))
' 31 (cerror "Ignore" "Loading the translations ~A for ~A failed."
' 32 ,base-name (cxx:name (qt:locale.system))))
' 33 (with-installed-translator ,translator
' 34 ,@body))))
' 35
2009-06-11 tobias 36 (defmacro qt:with-libqt-translator (&body body)
2010-01-10 tobias 37 "Loads the translations for the Qt library.
08:52:49 ' 38
' 39 Must be in a WITH-APP."
' 40 (let ((translator (gensym)))
2009-06-11 tobias 41 `(let ((,translator (make-instance 'qt:translator)))
2010-01-10 tobias 42 (unless (cxx:load ,translator (format nil "qt_~A"
08:52:49 ' 43 (cxx:name (qt:locale.system)))
' 44 (qt:library-info.location qt:library-info.+translations-path+))
' 45 (cerror "Ignore" "Loading the Qt library translations failed."))
' 46 (with-installed-translator ,translator
' 47 ,@body))))
' 48
2009-06-11 tobias 49 (defun qt:search-file (name &rest paths)
2010-01-10 tobias 50 "Searches the file NAME in PATHS and returns its path."
08:52:49 ' 51 (let ((file-path (find-if #'(lambda (path)
' 52 (probe-file (merge-pathnames name path)))
' 53 paths)))
' 54 (unless file-path
' 55 (error "The file ~S not found in the paths ~S" name paths))
' 56 (merge-pathnames name file-path)))
' 57