aboutsummaryrefslogtreecommitdiff
path: root/module/calp/translation.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-02-22 11:19:19 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-02-22 21:08:41 +0100
commit093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee (patch)
treed164e37c20e562588700d86379cfda1b0ca3c596 /module/calp/translation.scm
parentDatetime restrict imports. (diff)
downloadcalp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.gz
calp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.xz
Prepare code for translation.
Diffstat (limited to 'module/calp/translation.scm')
-rw-r--r--module/calp/translation.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/module/calp/translation.scm b/module/calp/translation.scm
new file mode 100644
index 00000000..c0392d95
--- /dev/null
+++ b/module/calp/translation.scm
@@ -0,0 +1,20 @@
+(define-module (calp translation)
+ :use-module (ice-9 i18n)
+ :use-module (ice-9 regex)
+ :use-module (ice-9 match)
+ :export (_ yes-no-check))
+
+(bindtextdomain "calp" "/home/hugo/code/calp/localization/")
+
+(define (_ . msg)
+ ;; NOTE this doesn't squeese repeated whitespace
+ (string-map (match-lambda
+ (#\newline #\space)
+ (c c))
+ (gettext (string-join msg) "calp")))
+
+(define* (yes-no-check string #:optional (locale %global-locale))
+ (cond ((string-match (locale-yes-regexp locale) string) 'yes)
+ ((string-match (locale-no-regexp locale) string) 'no)
+ (else #f)))
+