blob: 67189e7a167e69d02360d15116246fbb755b41e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
(define-module (calp translation)
:use-module (ice-9 i18n)
:use-module (ice-9 regex)
:use-module (ice-9 match)
:use-module (srfi srfi-88)
:export (_ translate yes-no-check))
(bindtextdomain "calp" "/home/hugo/code/calp/localization/")
;; Translate string, but doesn't mark it for translation.
;; Used (at least) for get-config introspection procedures.
(define (translate string)
;; NOTE this doesn't squeese repeated whitespace
(string-map (match-lambda
(#\newline #\space)
(c c))
(gettext string "calp")))
;; Mark string for translation, and also make it discoverable for gettext
(define (_ . msg)
(translate (string-join msg)))
(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)))
|