From 79d59e0b333966e0dd978a72e74a81b9ea1f9db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 11 Apr 2022 19:03:45 +0200 Subject: Allow translation of non-extracted strings. --- module/calp/translation.scm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/calp/translation.scm b/module/calp/translation.scm index c0392d95..77c947da 100644 --- a/module/calp/translation.scm +++ b/module/calp/translation.scm @@ -2,16 +2,23 @@ :use-module (ice-9 i18n) :use-module (ice-9 regex) :use-module (ice-9 match) - :export (_ yes-no-check)) + :export (_ translate yes-no-check)) (bindtextdomain "calp" "/home/hugo/code/calp/localization/") -(define (_ . msg) + +;; 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-join msg) "calp"))) + (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) -- cgit v1.2.3