Commit b2d7e3d3 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

i18n working

parent 1e748f1e
...@@ -402,8 +402,6 @@ ...@@ -402,8 +402,6 @@
(define i18n-text (define i18n-text
(list)) (list))
(msg 123)
(define (mtext-lookup id) (define (mtext-lookup id)
(define (_ l) (define (_ l)
(cond (cond
...@@ -412,7 +410,9 @@ ...@@ -412,7 +410,9 @@
(let ((translations (cadr (car l)))) (let ((translations (cadr (car l))))
(if (<= (length translations) i18n-lang) (if (<= (length translations) i18n-lang)
(string-append (symbol->string id) " not translated") (string-append (symbol->string id) " not translated")
(list-ref translations i18n-lang)))) (let ((r (list-ref translations i18n-lang)))
(if (or (equal? r "") (equal? r " "))
(list-ref translations 0) r)))))
(else (_ (cdr l))))) (else (_ (cdr l)))))
(_ i18n-text)) (_ i18n-text))
......
...@@ -34,13 +34,27 @@ ...@@ -34,13 +34,27 @@
(setup db "stream") (setup db "stream")
(insert-entity-if-not-exists (insert-entity-if-not-exists
db "local" "app-settings2" "null" 1 db "local" "app-settings" "null" 2
(list (list
(ktv "user-id" "varchar" "No name yet...") (ktv "user-id" "varchar" "No name yet...")
(ktv "language" "int" 0) (ktv "language" "int" 0)
(ktv "house-count" "int" 0) (ktv "house-count" "int" 0)
(ktv "photo-id-count" "int" 0))) (ktv "photo-id-count" "int" 0)))
(define (get-setting-value name)
(ktv-get (get-entity db "local" 2) name))
(define (set-setting! key type value)
(update-entity
db "local" 2 (list (ktv key type value))))
(define (get/inc-setting key)
(let ((r (get-setting-value key)))
(set-setting! key "int" (+ r 1))
r))
(set! i18n-lang (get-setting-value "language"))
(define entity-types (list "village" "household" "individual")) (define entity-types (list "village" "household" "individual"))
;;(display (db-all db "local" "app-settings"))(newline) ;;(display (db-all db "local" "app-settings"))(newline)
...@@ -528,7 +542,15 @@ ...@@ -528,7 +542,15 @@
(mbutton-scale 'sync (lambda () (list (start-activity "sync" 0 ""))))) (mbutton-scale 'sync (lambda () (list (start-activity "sync" 0 "")))))
(horiz (horiz
(mspinner 'languages (list 'english 'khasi 'hindi) (lambda (c) (list))) (mspinner 'languages (list 'english 'khasi 'hindi)
(lambda (c)
(set-setting! "language" "int"
(cond
((equal? c "English") 0)
((equal? c "Khasi") 1)
((equal? c "Hindi") 2)))
(set! i18n-lang (get-setting-value "language"))
(list)))
(mbutton-scale 'find-individual (lambda () (list (start-activity "individual-chooser" choose-code ""))))) (mbutton-scale 'find-individual (lambda () (list (start-activity "individual-chooser" choose-code "")))))
(build-list-widget (build-list-widget
db "sync" 'villages "village" "village" (lambda () #f) db "sync" 'villages "village" "village" (lambda () #f)
...@@ -539,6 +561,8 @@ ...@@ -539,6 +561,8 @@
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) (lambda (activity arg)
(list (list
(update-widget 'spinner (get-id "languages-spinner") 'selection
(get-setting-value "language"))
(gps-start "gps" (lambda (loc) (gps-start "gps" (lambda (loc)
(set-current! 'location loc) (set-current! 'location loc)
(list (toast (string-append (list (toast (string-append
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment