declare-bundle![procedure] declare-bundle! bundle-specifier alistSRFI-29: Used to prepare a bundle for srfi-29 based localization. Declares a new bundle named by the given bundle-specifier. The contents of the bundle are defined by alist, which is an assoc list of Scheme symbol and message template (string). The declared bundle may be saved in implementation-specific format by store-bundle. Once stored, an application can load the bundle by load-bundle!, then use localized-template to obtain a message template according to the current locale settings (e.g. current-language, current-country, and current-locale-details). The following example is taken from srfi-29 document: (let ((translations
'(((en) . ((time . "Its ~a, ~a.")
(goodbye . "Goodbye, ~a.")))
((fr) . ((time . "~1@*~a, c'est ~a.")
(goodbye . "Au revoir, ~a."))))))
(for-each (lambda (translation)
(let ((bundle-name (cons 'hello-program (car translation))))
(if (not (load-bundle! bundle-name))
(begin
(declare-bundle! bundle-name (cdr translation))
(store-bundle! bundle-name)))))
translations))
(define localized-message
(lambda (message-name . args)
(apply format (cons (localized-template 'hello-program
message-name)
args))))
(let ((myname "Fred"))
(display (localized-message 'time "12:00" myname))
(display #\newline)
(display (localized-message 'goodbye myname))
(display #\newline))
;; Displays (English):
;; Its 12:00, Fred.
;; Goodbye, Fred.
;;
;; French:
;; Fred, c'est 12:00.
;; Au revoir, Fred.
| About This SiteHome Alphabetical Indexa b c d e f g h i j k l m n o p q r s t u v w x y z other ConceptsConcept:CaseSensitivity Concept:DocumentationFormat Concept:ExtendedLambdaList Concept:FileSystem Concept:FindAndAnyInCollection Concept:ForeignInterface Concept:HashTable Concept:Module Concept:Networking Concept:ObjectSystem Concept:Process Concept:RegularExpression Concept:UserGroup Implementations
External Links |