Make find-l10n a global function and locally define the alist
This commit is contained in:
parent
a05ec88b6a
commit
fd676936d2
3 changed files with 22 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
|||
:cl-sbt/utility
|
||||
:spacing)
|
||||
(:export
|
||||
:l10n
|
||||
:select
|
||||
:checkable
|
||||
:ctrl
|
||||
|
@ -21,6 +22,11 @@
|
|||
|
||||
(in-package :cl-sbt/form)
|
||||
|
||||
(defvar l10n '(("submit" ("en" "Submit" "de" "Absenden" "fr" "Soumettre"))
|
||||
("cancel" ("en" "Cancel" "de" "Abbrechen" "fr" "Annuler"))
|
||||
("upload" ("en" "Upload" "de" "Hochladen" "fr" "Télécharger"))
|
||||
("search" ("en" "Search" "de" "Suchen" "fr" "Cherchent"))))
|
||||
|
||||
(defun remove-special-chars (str)
|
||||
"Removes all special characters from the string STR except numbers and
|
||||
alphabets.
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
(:use :cl)
|
||||
(:export
|
||||
:write-html-to-file
|
||||
:with-page))
|
||||
:with-page
|
||||
:find-l10n))
|
||||
|
||||
(in-package :cl-sbt)
|
||||
|
||||
|
@ -35,3 +36,11 @@
|
|||
(spinneret:*fill-column* fc))
|
||||
(with-open-file (stream filename :direction :output :if-exists :supersede)
|
||||
(write-string string stream))))
|
||||
|
||||
(defun find-l10n (key lang alist)
|
||||
"Finds the localized string for a given key and language.
|
||||
|
||||
KEY: The key to look up the localization for.
|
||||
|
||||
LANG: The language to get the localized string for."
|
||||
(cadr (member lang (cadr (assoc key alist :test #'string=)) :test #'string=)))
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
(defpackage cl-sbt/questionnaire
|
||||
(:use
|
||||
:cl)
|
||||
(:import-from
|
||||
:cl-sbt
|
||||
:find-l10n)
|
||||
(:import-from
|
||||
:cl-sbt/btn
|
||||
:btn-primary)
|
||||
|
@ -28,9 +31,9 @@
|
|||
:spacing)
|
||||
(:import-from
|
||||
:cl-sbt/form
|
||||
:find-l10n
|
||||
:l10n
|
||||
:checkable
|
||||
:ctrl-1)
|
||||
:ctrl)
|
||||
(:export
|
||||
:question
|
||||
:questionnaire))
|
||||
|
@ -188,4 +191,4 @@ Example 4:
|
|||
(let ((splitted-choices (split-plist-by-keyword choices)))
|
||||
`(question ,ask ,group ,@splitted-choices))))
|
||||
(btn-primary (:type "submit")
|
||||
(find-l10n "submit" spinneret:*html-lang*)))))
|
||||
(find-l10n "submit" spinneret:*html-lang* cl-sbt/form:l10n)))))
|
||||
|
|
Loading…
Add table
Reference in a new issue