This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi, What do you think about using #"hello" for gettext stings which need localization? This would be easy to write and easy to identifier for a program that extracts localization strings. This simple program for example: #! /usr/bin/guile \ -e main -s !# (load "locale.scm") (define (main args) (display "Hello World!") (newline) (display #"\"Hello World!\" that needs localization!") (newline)) would produce with this locale.scm file: (define (gettext str) "gettext dummy function" (string-append "[translation of: " str "]")) (read-hash-extend #\" (lambda (c port) (let ((char-list '())) (let loop ((char (read-char port))) (case char ((#\") (gettext (list->string char-list))) (else (if (eq? char #\\) (set! char (let ((char (read-char port))) (case char ((#\n) #\nl) ((#\t) #\ht) (else char))))) (set! char-list (append char-list (list char))) (loop (read-char port)))))))) this output: szi@olivia:~$ ./hello-world.scm Hello World! [translation of: "Hello World!" that needs localization!] The extraction of localization strings could look like this: #! /usr/bin/guile \ -e main -s !# (load "locale.scm") (define filename "") (define (gettext str) (display filename) (display ": ") (write str) (newline)) (define (main args) (if (pair? (cdr args)) (set! filename (cadr args))) (if (access? filename R_OK) (let ((port (open-input-file filename))) (display "Starting gettext extraction for ") (write filename) (newline) (let loop ((obj (read port))) (if (eof-object? obj) (close-input-port port) (loop (read port))))) (error "Can't read file\n"))) Although I have no idea why this script produces such an error: szi@olivia:~$ ./extract-locale-strings.scm hello-world.scm Starting gettext extraction for "hello-world.scm" hello-world.scm: "\"Hello World!\" that needs localization!" guile: Unknown # object: #\" -- http://www.ping.de/sites/aibon/