From 495ed87f0919152ea72234f78b94c4c9830d6273 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Fri, 23 Jun 2023 11:28:34 -0500 Subject: [PATCH] Baseline support for translations! :D MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not using gettext or anything, just a simple system I cooked up for having the translations hard-coded in, side-by-side. … it’s easier for me this way when writing, and it’ll make things easier later on, during distribution :P --- dialogue.lisp | 24 ++++++++++++++---------- flora-search-aurora.lisp | 24 +++++++++++++++++------- util.lisp | 11 ++++++++++- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/dialogue.lisp b/dialogue.lisp index 4214bc8..fbe4bdf 100644 --- a/dialogue.lisp +++ b/dialogue.lisp @@ -21,7 +21,8 @@ (:nicknames :fsa.dia :dialogue :💬) (:use :cl) (:export #:dialogue-state - #:start-dialogue #:face #:say #:mumble #:move)) + #:start-dialogue #:face #:say #:mumble #:move + :normal-face :talking-face)) (in-package :flora-search-aurora.dialogue) @@ -56,20 +57,22 @@ If not, have some tea on me: I’m paying. =w=" (list :speaker speaker :face face))) -(defun say (speaker text) +(defun say (speaker &rest text) (list - (list :speaker speaker :text text :face 'talking-face :progress 0) + (list :speaker speaker :face 'talking-face :progress 0 + :text (or (getf text (…:system-language)) (getf text :en))) (car (face speaker 'normal-face)))) -(defun mumble (speaker text) +(defun mumble (speaker &rest text) (list - (list :speaker speaker :text text :progress 0))) + (list :speaker speaker :progress 0 + :text (or (getf text (…:system-language)) (getf text :en))))) -(defun move (speaker world-coords) +(defun move (speaker world-coords &key (delay .05)) (list - (list :speaker speaker :coords world-coords))) + (list :speaker speaker :coords world-coords :delay delay))) @@ -140,7 +143,8 @@ coordinates listed in the DIALOGUE’s :COORDS property. … If applicable, ofc. ('t 0)) :y (cond ((< (getf target-coords :y) (getf speaker-coords :y)) -1) ((> (getf target-coords :y) (getf speaker-coords :y)) 1) - ('t 0)))) + ('t 0))) + (sleep (or (getf dialogue :delay) 0))) finished-moving-p)) @@ -279,8 +283,8 @@ and max-row; for use with RENDER-STRING. Like so: ;; … Worst-case scenario, just do whatever’ll fit :w:” (optimal-text-placement-vertically text coords :width width :height height :downp (not playerp)) - (optimal-text-palcement-horizontally text coords :width width :height height - :rightp (not leftp))))) + (optimal-text-placement-horizontally text coords :width width :height height + :rightp (not leftp))))) (defun render-dialogue-block (matrix map dialogue) diff --git a/flora-search-aurora.lisp b/flora-search-aurora.lisp index f2dc644..1abfdd1 100644 --- a/flora-search-aurora.lisp +++ b/flora-search-aurora.lisp @@ -38,17 +38,25 @@ (in-package :flora-search-aurora) + (defun literary-girl-dialogue-2 (map) (print "OWO")) + (defun literary-girl-dialogue (map) - (lambda (matrix &key (map map) - (dialogue (💬:start-dialogue - (💬:say "literary-girl" "Blah blah, testing. A multi-lined one. For real! jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj akls djlaks jdlaksj dlakjsd") - (💬:say "player" "ktp ktp jes jes?") - (💬:move "player" '(:x 30 :y 10))))) - (🌍:overworld-state-draw matrix map) - (💬:dialogue-state matrix :map map :dialogue dialogue))) + (let + ((dialogue + (💬:start-dialogue + (💬:mumble "literary-girl" :en "...") + (💬:say "player" :eo "Kielas apud la mar'?" + :en "How's the view?") + (💬:face "player" "<.<") + (💬:say "literary-girl" :eo "Kielas apud la ruinoj de via viv'?" + :en "How's your trainwreck of a life?") + (💬:face "player" '💬:normal-face)))) + (lambda (matrix &key (map map) (dialogue dialogue)) + (🌍:overworld-state-draw matrix map) + (💬:dialogue-state matrix :map map :dialogue dialogue)))) (defun state-loop @@ -109,6 +117,8 @@ with STATE-LOOP." ((label . "QUIT") (return . nil)))) + + (defun main () "A pathetic fascimile of a main loop. What does it do? WHAST DOES TI DODOO?" (cl-charms:with-curses () diff --git a/util.lisp b/util.lisp index 616b1b6..d99d20c 100644 --- a/util.lisp +++ b/util.lisp @@ -20,7 +20,7 @@ (defpackage :flora-search-aurora.util (:nicknames :fsa.ut :util :…) (:use :cl :assoc-utils) - (:export #:split-string-by-length #:plist= #:at-least #:at-most)) + (:export #:split-string-by-length #:plist= #:at-least #:at-most #:system-language)) (in-package :flora-search-aurora.util) @@ -69,3 +69,12 @@ minimum returns your more pitiful of moments." (if (> num maximum) maximum num)) + + +(defun system-language () + "Return the system language, if among the supported; otherwise, EN-glish." + (let ((lang (subseq (uiop:getenv "LANG") 0 2))) + (cond + ((string-equal lang "eo") :eo) + ((string-equal lang "en") :en) + ('t :en))))