Commit 010db8db authored by Daniel Kochmański's avatar Daniel Kochmański

cosmetic: example white character fixes

Signed-off-by: 's avatarDaniel Kochmański <daniel@turtleware.eu>
parent 33e9830b
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
ordinary constant strings in his/her application, the user instead ordinary constant strings in his/her application, the user instead
precedes them with =#t=: precedes them with =#t=:
#+BEGIN_SRC common-lisp #+BEGIN_SRC lisp
==> #t"dum dum dum, piję rum" ==> #t"dum dum dum, piję rum"
"la la la, I drink in the spa" "la la la, I drink in the spa"
#+END_SRC #+END_SRC
...@@ -41,8 +41,10 @@ ...@@ -41,8 +41,10 @@
run-time while keeping application innards visually separated from run-time while keeping application innards visually separated from
the messages meant to be presented to user. the messages meant to be presented to user.
#+BEGIN_SRC common-lisp #+BEGIN_SRC lisp
==> (setf translate:*language* nil) ==> (setf translate:*language* nil)
NIL
==> (make-button :label #t"hello") ==> (make-button :label #t"hello")
#<button "hello"> #<button "hello">
#+END_SRC #+END_SRC
...@@ -51,14 +53,17 @@ ...@@ -51,14 +53,17 @@
translation. If no translation exists it will be temporarily translation. If no translation exists it will be temporarily
translated to the same value enclosed in a curly brackets: translated to the same value enclosed in a curly brackets:
#+BEGIN_SRC common-lisp #+BEGIN_SRC lisp
==> (translate:define-language :pl) ==> (translate:define-language :pl)
(#<hash-table 00000000054323c0> NIL #<compiled-function 0000000005fe08c0>) (#<hash-table 00000000054323c0> NIL #<compiled-function 0000000005fe08c0>)
==> (setf translate:*language* :pl) ==> (setf translate:*language* :pl)
:PL :PL
==> (make-label :text #t"Greetings, programs") ==> (make-label :text #t"Greetings, programs")
;;; Warning: phrase "Greetings, programs" isn't defined for language :PL. ;;; Warning: phrase "Greetings, programs" isn't defined for language :PL.
#<label "{Greetings, programs}"> #<label "{Greetings, programs}">
==> (make-label :text #t"Leave the grid") ==> (make-label :text #t"Leave the grid")
;;; Warning: phrase "Leave the grid" isn't defined for language :PL. ;;; Warning: phrase "Leave the grid" isn't defined for language :PL.
#<label "{Leave the grid}"> #<label "{Leave the grid}">
...@@ -76,7 +81,7 @@ ...@@ -76,7 +81,7 @@
convenient is using symbols as the language designators. It also convenient is using symbols as the language designators. It also
implies, that phrases meant for translation are case sensitive. implies, that phrases meant for translation are case sensitive.
** Adding translation ** Adding translation
To add translations, two interfaces are provided. The To add translations, two interfaces are provided. The
=ADD-SINGLE-TRANSLATION= function takes three arguments, where the =ADD-SINGLE-TRANSLATION= function takes three arguments, where the
...@@ -92,10 +97,12 @@ ...@@ -92,10 +97,12 @@
;;; Warning: Implicitly creating language PL. ;;; Warning: Implicitly creating language PL.
[PL] hello -> Witaj! [PL] hello -> Witaj!
"Witaj!" "Witaj!"
==> (translate:add-single-translation 'en "hello" "Welcome!") ==> (translate:add-single-translation 'en "hello" "Welcome!")
;;; Warning: Implicitly creating language EN. ;;; Warning: Implicitly creating language EN.
[EN] hello -> Welcome! [EN] hello -> Welcome!
"Welcome!" "Welcome!"
==> (translate:add-single-translation ==> (translate:add-single-translation
'pl "bang" 'pl "bang"
(let ((i 1)) (let ((i 1))
...@@ -104,7 +111,7 @@ ...@@ -104,7 +111,7 @@
bang -> #<bytecompiled-closure #<bytecompiled-function 00000000067d9f50>> (PL) bang -> #<bytecompiled-closure #<bytecompiled-function 00000000067d9f50>> (PL)
#<bytecompiled-closure #<bytecompiled-function 00000000067d9f50>> #<bytecompiled-closure #<bytecompiled-function 00000000067d9f50>>
#+END_SRC #+END_SRC
=ADD-TRANSLATIONS= is a simple wrapper around =ADD-TRANSLATIONS= is a simple wrapper around
=ADD-SINGLE-TRANSLATION= that allows the translation of multiple =ADD-SINGLE-TRANSLATION= that allows the translation of multiple
phrases in one form. The first argument is once again the phrases in one form. The first argument is once again the
...@@ -124,6 +131,7 @@ ...@@ -124,6 +131,7 @@
[PL] header-pricing -> Cennik [PL] header-pricing -> Cennik
[PL] header-contact -> Kontakt [PL] header-contact -> Kontakt
T T
==> (translate:add-translations 'en ==> (translate:add-translations 'en
"header-about" "About" "header-about" "About"
"header-offer" "Offer" "header-offer" "Offer"
...@@ -152,7 +160,7 @@ ...@@ -152,7 +160,7 @@
without translations, the function =MISSING-TRANSLATIONS= is without translations, the function =MISSING-TRANSLATIONS= is
available. It returns a list of the form ={((LANG (PHRASES*))*)}=. available. It returns a list of the form ={((LANG (PHRASES*))*)}=.
#+BEGIN_SRC lisp #+BEGIN_SRC lisp
==> (missing-translations) ==> (missing-translations)
((PL ("phrase-1" "phrase-2" "phrase-3")) ((PL ("phrase-1" "phrase-2" "phrase-3"))
(BG ("phrase-1" "phrase-3"))) (BG ("phrase-1" "phrase-3")))
...@@ -180,21 +188,27 @@ ...@@ -180,21 +188,27 @@
calls and they may work not as expected in the context where calls and they may work not as expected in the context where
enclosing macro prevents their evaluation. enclosing macro prevents their evaluation.
#+BEGIN_SRC common-lisp #+BEGIN_SRC lisp
==> (setf translate:*mode* :run-time) ==> (setf translate:*mode* :run-time)
:RUN-TIME :RUN-TIME
==> (setf translate:*language* :en) ==> (setf translate:*language* :en)
:EN :EN
==> (translate:add-single-translation :en "hello" "Hello") ==> (translate:add-single-translation :en "hello" "Hello")
[EN] hello -> Hello [EN] hello -> Hello
==> (translate:add-single-translation :pl "hello" "Cześć") ==> (translate:add-single-translation :pl "hello" "Cześć")
[PL] hello -> Cześć [PL] hello -> Cześć
==> (let ((translate:*language* :en)) ==> (let ((translate:*language* :en))
#t"hello") #t"hello")
"Hello" "Hello"
==> (let ((translate:*language* :pl)) ==> (let ((translate:*language* :pl))
#t"hello") #t"hello")
"Cześć" "Cześć"
==> (quote #t"hello") ==> (quote #t"hello")
(TRANSLATE:TRANSLATE "hello") (TRANSLATE:TRANSLATE "hello")
#+END_SRC #+END_SRC
...@@ -205,32 +219,42 @@ ...@@ -205,32 +219,42 @@
immediately. That also means that changing =TRANSLATE:*LANGUAGE*= immediately. That also means that changing =TRANSLATE:*LANGUAGE*=
in the future won't affect translations resolved earlier. in the future won't affect translations resolved earlier.
#+BEGIN_SRC common-lisp #+BEGIN_SRC lisp
==> (setf translate:*mode* :load-time) ==> (setf translate:*mode* :load-time)
:RUN-TIME :RUN-TIME
==> (setf translate:*language* :en) ==> (setf translate:*language* :en)
:EN :EN
==> (defparameter *my-function-1* ==> (defparameter *my-function-1*
(lambda () #t"hello")) (lambda () #t"hello"))
;;; Warning: phrase "hello" isn't defined for language EN. ;;; Warning: phrase "hello" isn't defined for language EN.
,*MY-FUNCTION-1* *MY-FUNCTION-1*
==> (translate:add-translation :en "hello" "Hello") ==> (translate:add-translation :en "hello" "Hello")
hello -> Hello (EN) hello -> Hello (EN)
==> (translate:add-translation :pl "hello" "Cześć") ==> (translate:add-translation :pl "hello" "Cześć")
hello -> Cześć (PL) hello -> Cześć (PL)
==> (let ((*language* :en)) ==> (let ((*language* :en))
#t"hello") #t"hello")
"Hello" "Hello"
==> (let ((*language* :pl)) ; lexical scope is ignored ==> (let ((*language* :pl)) ; lexical scope is ignored
#t"hello") #t"hello")
"Hello" "Hello"
==> (defparameter *my-function-2* ==> (defparameter *my-function-2*
(lambda () #t"hello")) (lambda () #t"hello"))
,*MY-FUNCTION-2* ,*MY-FUNCTION-2*
==> (funcall *my-function-1*) ; phrase wasn't translated when function was created ==> (funcall *my-function-1*) ; phrase wasn't translated when function was created
"{hello}" "{hello}"
==> (funcall *my-function-2*) ==> (funcall *my-function-2*)
"Hello" "Hello"
==> (quote #t"hello") ==> (quote #t"hello")
"Hello" "Hello"
#+END_SRC #+END_SRC
...@@ -252,7 +276,7 @@ ...@@ -252,7 +276,7 @@
used for comparison is EQL). If bound to NIL, translation works the used for comparison is EQL). If bound to NIL, translation works the
same way as the IDENTITY function. same way as the IDENTITY function.
#+END_SRC #+END_SRC
*** =*RESOLUTION-TIME*= *** =*RESOLUTION-TIME*=
#+BEGIN_SRC text #+BEGIN_SRC text
Applicable values are :LOAD-TIME and :RUN-TIME (the latter is the Applicable values are :LOAD-TIME and :RUN-TIME (the latter is the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment