Changeset 27220 in project


Ignore:
Timestamp:
08/07/12 16:45:55 (9 years ago)
Author:
Alex Shinn
Message:

Fixing mo file parsing and adding new tests.

Location:
release/4/free-gettext
Files:
4 added
3 edited
5 copied

Legend:

Unmodified
Added
Removed
  • release/4/free-gettext/tags/1.5/free-gettext.scm

    r27151 r27220  
    220220
    221221(define (make-gettext-file filename locale)
    222   (let* ((encoding (detect-file-encoding filename locale))
    223          (property-msg (lookup-message filename "" #f encoding))
     222  (let* ((file-type (if (string-suffix? ".mo" filename) 'mo 'po))
     223         (property-msg (lookup-message filename "" #f))
    224224         (properties (if property-msg
    225225                         (call-with-input-string property-msg
     
    232232         (encoding
    233233          (cond ((assoc "charset" content-type) => cdr)
    234                 (else encoding)))
     234                (else (detect-file-encoding filename locale))))
    235235         (plural-index
    236236          (cond
     
    242242                    (else (lambda (n) 0)))))
    243243            (else (lambda (n) 0)))))
    244     (%make-gfile filename
    245                  locale
    246                  encoding
    247                  properties
    248                  (if (string-suffix? ".mo" filename) 'mo 'po)
    249                  plural-index)))
     244    (%make-gfile filename locale encoding properties file-type plural-index)))
    250245
    251246;; take a list or a single argument which is interpretted as a one
     
    371366   (file-read-access? file)
    372367   (condition-case
    373        (with-input-from-encoded-file file encoding
     368       (with-input-from-file file
    374369         (lambda ()
    375370           (define (search read-int)
     
    435430       (if (pair? opt) (car opt) (gfile-encoding gfile)))
    436431      ((if (string-suffix? ".mo" gfile) lookup-mo-message lookup-po-message)
    437        gfile msg msg2 (if (pair? opt) (car opt) 'utf8))))
     432       gfile msg msg2 (if (pair? opt) (car opt) "utf8"))))
    438433
    439434;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  • release/4/free-gettext/tags/1.5/free-gettext.setup

    r27151 r27220  
    77 'free-gettext
    88 '("free-gettext.so" "free-gettext.import.so")
    9  '((version 1.4)))
     9 '((version 1.5)))
  • release/4/free-gettext/tags/1.5/test-free-gettext.scm

    r27151 r27220  
    1919      "芭蕉野分しお\nたらいに雚を\n聎く倜かな\n")
    2020     ("Clouds will separate\nThe two friends, after the migrating\nWild goose's departure\n"
    21       "雲ず隔぀\n友かや雁の\n生き別れ\n"))))
     21      "雲ず隔぀\n友かや雁の\n生き別れ\n"))
     22    ))
    2223
    2324(define *plural-tests*
     
    9596    '("en" "ja")))
    9697
    97  '("test"))
     98 '("test" "motest"))
    9899
    99100(test-end)
  • release/4/free-gettext/trunk/free-gettext.scm

    r27151 r27220  
    220220
    221221(define (make-gettext-file filename locale)
    222   (let* ((encoding (detect-file-encoding filename locale))
    223          (property-msg (lookup-message filename "" #f encoding))
     222  (let* ((file-type (if (string-suffix? ".mo" filename) 'mo 'po))
     223         (property-msg (lookup-message filename "" #f))
    224224         (properties (if property-msg
    225225                         (call-with-input-string property-msg
     
    232232         (encoding
    233233          (cond ((assoc "charset" content-type) => cdr)
    234                 (else encoding)))
     234                (else (detect-file-encoding filename locale))))
    235235         (plural-index
    236236          (cond
     
    242242                    (else (lambda (n) 0)))))
    243243            (else (lambda (n) 0)))))
    244     (%make-gfile filename
    245                  locale
    246                  encoding
    247                  properties
    248                  (if (string-suffix? ".mo" filename) 'mo 'po)
    249                  plural-index)))
     244    (%make-gfile filename locale encoding properties file-type plural-index)))
    250245
    251246;; take a list or a single argument which is interpretted as a one
     
    371366   (file-read-access? file)
    372367   (condition-case
    373        (with-input-from-encoded-file file encoding
     368       (with-input-from-file file
    374369         (lambda ()
    375370           (define (search read-int)
     
    435430       (if (pair? opt) (car opt) (gfile-encoding gfile)))
    436431      ((if (string-suffix? ".mo" gfile) lookup-mo-message lookup-po-message)
    437        gfile msg msg2 (if (pair? opt) (car opt) 'utf8))))
     432       gfile msg msg2 (if (pair? opt) (car opt) "utf8"))))
    438433
    439434;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  • release/4/free-gettext/trunk/free-gettext.setup

    r27151 r27220  
    77 'free-gettext
    88 '("free-gettext.so" "free-gettext.import.so")
    9  '((version 1.4)))
     9 '((version 1.5)))
  • release/4/free-gettext/trunk/test-free-gettext.scm

    r27151 r27220  
    1919      "芭蕉野分しお\nたらいに雚を\n聎く倜かな\n")
    2020     ("Clouds will separate\nThe two friends, after the migrating\nWild goose's departure\n"
    21       "雲ず隔぀\n友かや雁の\n生き別れ\n"))))
     21      "雲ず隔぀\n友かや雁の\n生き別れ\n"))
     22    ))
    2223
    2324(define *plural-tests*
     
    9596    '("en" "ja")))
    9697
    97  '("test"))
     98 '("test" "motest"))
    9899
    99100(test-end)
Note: See TracChangeset for help on using the changeset viewer.