add localisation support, allow multi-languages

This commit is contained in:
Xuan Sang LE
2018-03-09 19:54:33 +01:00
parent 696114e2f7
commit 9e0cd29030
27 changed files with 370 additions and 170 deletions

View File

@ -10,36 +10,36 @@ self.OS.API.handler =
scandir: (p, c ) ->
path = "#{_REST}/fs/scandir"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to scan directory: #{p}", e, s
_courrier.osfail __("Fail to scan directory: {0}", p), e, s
mkdir: (p, c ) ->
path = "#{_REST}/fs/mkdir"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to create directory: #{p}", e, s
_courrier.osfail __("Fail to create directory: {0}", p), e, s
sharefile: (p, pub , c) ->
path = "#{_REST}/fs/publish"
_API.post path, { path: p , publish: pub }, c, (e, s) ->
_courrier.osfail "Fail to publish file: #{p}", e, s
_courrier.osfail __("Fail to publish file: {0}", p), e, s
fileinfo: (p, c) ->
path = "#{_REST}/fs/fileinfo"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to get file metadata: #{p}", e, s
_courrier.osfail __("Fail to get file meta data: {0}", p), e, s
readfile: (p, c, t) ->
path = "#{_REST}/fs/get/"
_API.get path + p, c, (e, s) ->
_courrier.osfail "Fail to read file: #{p}", e, s
_courrier.osfail __("Fail to read file: {0}", p), e, s
, t
move: (s, d, c) ->
path = "#{_REST}/fs/move"
_API.post path, { src: s, dest: d }, c, (e, s) ->
_courrier.osfail "Fail to move file: #{s} -> #{d}", e, s
_courrier.osfail __("Fail to move file: {0} -> {1}", s, d), e, s
delete: (p , c) ->
path = "#{_REST}/fs/delete"
_API.post path, { path: p }, c, (e, s) ->
_courrier.osfail "Fail to delete: #{p}", e, s
_courrier.osfail __("Fail to delete: {0}", p), e, s
fileblob: (p, c) ->
path = "#{_REST}/fs/get/"
@ -49,44 +49,44 @@ self.OS.API.handler =
packages: (d, c) ->
path = "#{_REST}/system/packages"
_API.post path, d, c, (e, s) ->
_courrier.osfail "Fail to #{d.command} package", e, s
_courrier.osfail __("Fail to {0} package", d.command), e, s
upload: (d, c) ->
path = "#{_REST}/fs/upload"
_API.upload path, d, c, (e, s) ->
_courrier.osfail "Fail to upload file to: #{d}", e, s
_courrier.osfail __("Fail to upload file to: {0}", d), e, s
write: (p, d , c) ->
path = "#{_REST}/fs/write"
_API.post path, { path: p, data: d }, c, (e, s) ->
_courrier.osfail "Fail to write to file: #{p}", e, s
_courrier.osfail __("Fail to write to file: {0}", p), e, s
scanapp: (p, c ) ->
path = "#{_REST}/system/application"
auth: (c) ->
p = "#{_REST}/system/auth"
_API.post p, {}, c, () ->
alert "Resource not found: #{p}"
alert __("Resource not found: {0}", p)
login: (d, c) ->
p = "#{_REST}/system/login"
_API.post p, d, c, () ->
alert "Resource not found: #{p}"
alert __("Resource not found: {0}", p)
logout: () ->
p = "#{_REST}/system/logout"
_API.post p, {}, (d) ->
_OS.boot()
, () ->
alert "Resource not found #{p}"
alert __("Resource not found: {0}", p)
setting: (f) ->
p = "#{_REST}/system/settings"
_API.post p, _OS.setting, (d) ->
_courrier.oserror "Cannot save system setting", d.error if d.error
_courrier.oserror __("Cannot save system setting"), d.error if d.error
f() if f
, (e, s) ->
_courrier.osfail "Fail to make request: #{p}", e, s
_courrier.osfail __("Fail to make request: {0}", p), e, s
f() if f
dbquery: (cmd, d, c) ->
path = "#{_REST}/db/#{cmd}"
_API.post path, d, c, (e, s) ->
_courrier.osfail "Fail to query data from database: #{path}", e, s
_courrier.osfail __("Fail to query data from database: {0}", path), e, s