initial import
Annotate for file src/i18n.lisp
2009-04-05 tobias 1 (in-package :qt)
17:56:16 ' 2
' 3 (defun tr (message &optional context)
' 4 "Returns the translated MESSAGE for CONTEXT or
' 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
' 17 (defmacro with-translator (base-name &body body)
' 18 "Loads the translations in the BASE-NAME_LANGCODE.qm file.
' 19
' 20 Must be in a WITH-APP."
' 21 (let ((translator (gensym)))
' 22 `(let ((,translator (make-instance 'translator)))
' 23 (unless (cxx:load ,translator (format nil "~A_~A"
' 24 ,base-name
' 25 (cxx:name (qt:locale.system))))
' 26 (cerror "Ignore" "Loading the translations ~A for ~A failed."
' 27 ,base-name (cxx:name (qt:locale.system))))
' 28 (with-installed-translator ,translator
' 29 ,@body))))
' 30
' 31 (defmacro with-libqt-translator (&body body)
' 32 "Loads the translations for the Qt library.
' 33
' 34 Must be in a WITH-APP."
' 35 (let ((translator (gensym)))
' 36 `(let ((,translator (make-instance 'translator)))
' 37 (unless (cxx:load ,translator (format nil "qt_~A"
' 38 (cxx:name (qt:locale.system)))
' 39 (qt:library-info.location qt:library-info.+translations-path+))
' 40 (cerror "Ignore" "Loading the Qt library translations failed."))
' 41 (with-installed-translator ,translator
' 42 ,@body))))