Translations of menu-items ^_^

This commit is contained in:
Jaidyn Ann 2023-06-23 12:54:29 -05:00
parent dafccb17a1
commit e21d16069b
4 changed files with 22 additions and 13 deletions

View File

@ -60,14 +60,14 @@ If not, have some tea on me: Im paying. =w="
(defun say (speaker &rest text) (defun say (speaker &rest text)
(list (list
(list :speaker speaker :face 'talking-face :progress 0 (list :speaker speaker :face 'talking-face :progress 0
:text (or (getf text (:system-language)) (getf text :en))) :text (:getf-lang text))
(car (face speaker 'normal-face)))) (car (face speaker 'normal-face))))
(defun mumble (speaker &rest text) (defun mumble (speaker &rest text)
(list (list
(list :speaker speaker :progress 0 (list :speaker speaker :progress 0
:text (or (getf text (:system-language)) (getf text :en))))) :text (:getf-lang text))))
(defun move (speaker world-coords &key (delay .05)) (defun move (speaker world-coords &key (delay .05))

View File

@ -17,7 +17,7 @@
;;;; A simple TUI-game made for the text-flavoured LibreJam of 2023-06! ;;;; A simple TUI-game made for the text-flavoured LibreJam of 2023-06!
;;;; See: https://jamgaroo.xyz/jams/2 ;;;; See: https://jamgaroo.xyz/jams/2
(ql:quickload '(alexandria assoc-utils cl-charms cl-tiled str)) (ql:quickload '(alexandria anaphora assoc-utils cl-charms cl-tiled str))
(load "util.lisp") (load "util.lisp")
(load "input.lisp") (load "input.lisp")
@ -107,16 +107,17 @@ with STATE-LOOP."
args)))) args))))
(defparameter *submenu* `(((label . "IDK") (selection . 100) (selected t)) (defparameter *submenu* `(((LABEL :en "IDK") (selection . 100) (selected t))
((label . "GO BACK") (return . nil)))) ((LABEL :en "GO BACK") (return . nil))))
(defparameter *main-menu* `(((label . "PLAY") (selection . 100) (selected . t) (defparameter *main-menu* `(((LABEL :en "PLAY" :eo "EKLUDI")
(selection . 100) (selected . t)
(return . ,(make-main-overworld-state))) (return . ,(make-main-overworld-state)))
((label . "SUBMENU") (return . ,(📋:make-menu-state *submenu*))) ((LABEL :en "SUBMENU" :eo "SUBMENUO")
((label . "QUIT") (return . nil)))) (return . ,(📋:make-menu-state *submenu*)))
((LABEL :en "QUIT" :eo "REZIGNI")
(return . nil))))
(defun main () (defun main ()

View File

@ -111,11 +111,12 @@ left-to-right, unless negative — in which case, right-to-left."
"Render several menu items to the matrix, starting at the given x/y coordinates, "Render several menu items to the matrix, starting at the given x/y coordinates,
maximum width for any given item, and the height of all items. maximum width for any given item, and the height of all items.
The item list should be an alist of the following format: The item list should be an alist of the following format:
(((LABEL . FOO)(SELECTED . T)(SELECTION . 100)) ((LABEL . BAR)(SELECTION . -20)) )" (((LABEL :en BIRD :eo BIRDO)(SELECTED . T)(SELECTION . 100))
((LABEL :en BAR :eo BARO)(SELECTION . -20)) )"
(let ((x x)) (let ((x x))
(mapcar (mapcar
(lambda (item) (lambda (item)
(let* ((label (cdr (assoc 'label item))) (let* ((label (:getf-lang (cdr (assoc 'label item))))
(selection (or (cdr (assoc 'selection item)) (selection (or (cdr (assoc 'selection item))
0)) 0))
(width (:at-most max-item-width (width (:at-most max-item-width

View File

@ -23,7 +23,7 @@
(:export #:split-string-by-length (:export #:split-string-by-length
#:plist= #:plist=
#:at-least #:at-most #:at-least #:at-most
#:system-language #:langcode->keysym)) #:system-language #:langcode->keysym #:getf-lang))
(in-package :flora-search-aurora.util) (in-package :flora-search-aurora.util)
@ -88,3 +88,10 @@ if the language is among the supported. Otherwise, nil."
"Return the system language, if among the supported; otherwise, EN-glish." "Return the system language, if among the supported; otherwise, EN-glish."
(or (langcode->keysym (uiop:getenv "LANG")) (or (langcode->keysym (uiop:getenv "LANG"))
:en)) :en))
(defun getf-lang (plist &optional (language (system-language)) (fallback-lang :en))
"With a plist containing keys of language-codes, return the property either fitting the
preferred LANGUAGE, or the backup FALLBACK-LANG (if LANGUAGEs is NIL)."
(or (getf plist language)
(getf plist fallback-lang)))