aboutsummaryrefslogtreecommitdiff
path: root/module/calp/translation.scm
blob: c0392d9560539caf76434d55a200f4de0a3d7832 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)))