You can use qt:tr
to translate strings.
Example 3.3. i18n Hello World
;;; Copyright 2009 Tobias Rautenkranz ;;; License: X11 license (in-package :qt.examples) (defun i18n-hello-world () "i18n hello world" (qt:with-app () (qt:with-translator ("hello-world" *default-pathname-defaults* *source-path*) (let ((widget (make-instance 'qt:label))) (setf (cxx:window-title widget) (qt:tr "Lisp Qt Example" "hello-world") (cxx:text widget) (format nil (qt:tr "<h1>Hello world</h1> You are running ~A version ~A on a ~A ~A") (lisp-implementation-type) (lisp-implementation-version) (software-type) (software-version))) (cxx:show widget) (qt:exec))))) ;; FIXME: ;; calling #'software-version from the qt:application event loop ;; segfaults in SBCL. The first call caches the result in ;; sb-sys::*software-version* and we thus prevent the crash in ;; (run-program "/bin/uname" [...]). #+sbcl (smoke:eval-startup (:load-toplevel) (software-version))
hello-world_de.po
.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # # Tobias Rautenkranz <tobias@rautenkranz.ch>, 2009. msgid "" msgstr "" "Project-Id-Version: hello-world\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2009-07-01 01:17+0200\n" "PO-Revision-Date: 2009-03-21 11:41+0100\n" "Last-Translator: Tobias Rautenkranz <tobias@rautenkranz.ch>\n" "Language-Team: German <>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Lokalize 0.3\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" #: i18n-hello-world.lisp:21 msgctxt "hello-world" msgid "Lisp Qt Example" msgstr "Lisp Qt Beispiel" #: i18n-hello-world.lisp:22 #, lisp-format msgid "" "<h1>Hello world</h1>\n" "\n" "You are running ~A version ~A on a ~A ~A" msgstr "" "<h1>Hallo Welt</h1>\n" "\n" "Du verwendest, auf ~2@*~A ~A, ~0@*~A version ~A"
Gettext is used to extract the i18n strings and compile the message catalog.
See CMakeLists.txt
and UseClQti18n.cmake
in the src/
directory of :cl-smoke.qt.examples on how to do this.