repos
/
qt.core
/ annotate_shade
summary
|
shortlog
|
log
|
tree
|
commit
|
commitdiff
|
headdiff
|
annotate
|
headblob
|
headfilediff
|
filehistory
normal
|
plain
|
shade
|
zebra
Split up in qt.core.
Annotate for file /src/i18n.lisp
2010-01-10 tobias
1
(in-package :cl-smoke.qt.core)
2009-04-05 tobias
2
2009-06-11 tobias
3
(defun qt:tr (message &optional context)
2009-04-05 tobias
4
"Returns the translated MESSAGE for CONTEXT or
17:56:16 '
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)
2009-05-14 tobias
18
"Loads the translations in the BASE-NAME_LANGCODE.qm file;
12:11:11 '
19
searching PATHS.
2009-04-05 tobias
20
17:56:16 '
21
Must be in a WITH-APP."
'
22
(let ((translator (gensym)))
2009-06-11 tobias
23
`(let ((,translator (make-instance 'qt:translator)))
2009-05-14 tobias
24
(unless
12:11:11 '
25
(find-if #'(lambda (path)
'
26
(cxx:load ,translator
'
27
(format nil "~A_~A" ,base-name
2009-05-19 tobias
28
(cxx:name (qt:locale.system)))
15:16:49 '
29
(namestring path)))
2009-05-14 tobias
30
(list ,@paths))
2009-04-05 tobias
31
(cerror "Ignore" "Loading the translations ~A for ~A failed."
17:56:16 '
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)
2009-04-05 tobias
37
"Loads the translations for the Qt library.
17:56:16 '
38
'
39
Must be in a WITH-APP."
'
40
(let ((translator (gensym)))
2009-06-11 tobias
41
`(let ((,translator (make-instance 'qt:translator)))
2009-04-05 tobias
42
(unless (cxx:load ,translator (format nil "qt_~A"
17:56:16 '
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))))
2009-05-14 tobias
48
2009-06-11 tobias
49
(defun qt:search-file (name &rest paths)
2009-05-14 tobias
50
"Searches the file NAME in PATHS and returns its path."
12:11:11 '
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