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

@ -14,7 +14,7 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
app = _PM.appByPid item[0].value
app.quit() if app
header = [{width:50,value:"Pid"},{value:"Name"}, {value:"Type", width:80},{width:75,value:"Alive (ms)"}]
header = [{width:50,value:__("Pid")},{value:__("Name")}, {value:__("Type"), width:80},{width:75,value:__("Alive (ms)")}]
@gdata =
processes:{}
alive:[]
@ -36,7 +36,7 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
{icon:if _APP[a.name].type == 1 then _APP[a.name].meta.icon else a.icon,
iconclass:if _APP[a.name].type == 1 then _APP[a.name].meta.iconclass else a.iconclass,
value:a.name},
{value: if _APP[a.name].type == 1 then "Application" else "Service"}
{value: if _APP[a.name].type == 1 then __("Application") else __("Service")}
{value: now - a.birth}
]
me.gdata.alive.push a.pid

View File

@ -1,6 +1,6 @@
<afx-app-window data-id = "am-window" apptitle="" width="400" height="300">
<afx-vbox>
<afx-grid-view data-id = "mygrid"></afx-grid-view>
<afx-button data-height="30" data-id = "btkill" text = "Kill process" iconclass="fa fa-times"></afx-button>
<afx-button data-height="30" data-id = "btkill" text = "__(Kill process)" iconclass="fa fa-times"></afx-button>
</afx-vbox>
</afx-app-window>

View File

@ -2,30 +2,30 @@
<afx-vbox >
<div data-height="5"></div>
<afx-hbox data-height = "30" >
<afx-label data-width= "70" text = "Title:"></afx-label>
<afx-label data-width= "70" text = "__(Title)"></afx-label>
<input type = "text" name="title" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "Subtitle:" data-width= "70"></afx-label>
<afx-label text = "__(Subtitle)" data-width= "70"></afx-label>
<input type = "text" name="subtitle" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "Location:" data-width= "70"></afx-label>
<afx-label text = "__((Location))" data-width= "70"></afx-label>
<input type = "text" name="location" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30" >
<afx-label text = "From:" data-width= "70"></afx-label>
<afx-label text = "__(From)" data-width= "70"></afx-label>
<input type = "text" name="start" input-class = "user-input"/>
<afx-label text = "To:" style="text-align:center;" data-width= "70"></afx-label>
<input type = "text" name="end" input-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "Content:" style = "margin-left:5px;"/>
<afx-label data-height = "30" text = "Content" style = "margin-left:5px;"/>
<div data-id="editor-container">
<textarea name="content" data-id = "contentarea" />
</div>
<afx-hbox data-height = "35">
<div></div>
<afx-button iconclass = "fa fa-save" data-id = "bt-cv-sec-save" data-width="60" text = "Save"/>
<afx-button iconclass = "fa fa-save" data-id = "bt-cv-sec-save" data-width="60" text = "__(Save)"/>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -2,9 +2,9 @@ class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
constructor: () ->
super "BloggerCategoryDialog", {
tags: [
{ tag: "afx-label", att: "data-height = '20', text = 'Pick a parent:'" },
{ tag: "afx-label", att: "data-height = '20', text = 'Pick a parent'" },
{ tag: "afx-tree-view" },
{ tag: "afx-label", att: "data-height = '20', text = 'Category name:'" },
{ tag: "afx-label", att: "data-height = '20', text = 'Category name'" },
{ tag: "input", att: "type = 'text' data-height = '20'" }
],
width: 200,
@ -15,10 +15,10 @@ class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
label: "0k",
onclick: (d) ->
sel = (d.find "content1").get "selectedItem"
return d.notify "Please select a parent category" unless sel
return d.notify __("Please select a parent category") unless sel
val = (d.find "content3").value
return d.notify "Please enter category name" if val is "" and not d.data.selonly
return d.notify "Parent can not be the category itself" if d.data.cat and d.data.cat.id is sel.id
return d.notify __("Please enter category name") if val is "" and not d.data.selonly
return d.notify __("Parent can not be the category itself") if d.data.cat and d.data.cat.id is sel.id
d.handler { p: sel, value: val } if d.handler
d.quit()
},
@ -66,7 +66,7 @@ class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog
($ (@select '[class="CodeMirror cm-s-paper CodeMirror-wrap"]')[0]).css "min-height", "50px"
@on "vboxchange", () ->
me.resizeContent()
console.log "resize content"
inputs = me.select "[input-class='user-input']"
(($ v).val me.data[v.name] for v in inputs ) if me.data
@editor.value me.data.content if me.data and me.data.content
@ -75,7 +75,7 @@ class BloggerCVSectionDiaglog extends this.OS.GUI.BaseDialog
console.log inputs
data[v.name] = ($ v).val() for v in inputs
data.content = me.editor.value()
return me.notify "Title or content must not be blank" if data.title is "" and data.content is ""
return me.notify __("Title or content must not be blank") if data.title is "" and data.content is ""
#return me.notify "Content must not be blank" if data.content is ""
data.id = me.data.id if me.data and me.data.id
me.handler data if me.handler

View File

@ -42,11 +42,11 @@ class Blogger extends this.OS.GUI.BaseApplication
pid: d.p.id,
publish: 1
me.cvcatdb.save c, (r) ->
me.error "Cannot add new category" if r.error
me.error __("Cannot add new category") if r.error
me.refreshCVCat()
#update the list
, "Add category", { tree: me.cvlist.get "data" }
, __("Add category"), { tree: me.cvlist.get "data" }
(@find "cv-cat-edit").set "onbtclick", (e) ->
cat = me.cvlist.get "selectedItem"
@ -59,9 +59,9 @@ class Blogger extends this.OS.GUI.BaseApplication
name: d.value
me.cvcatdb.save c, (r) ->
return me.error "Cannot Edit category" if r.error
return me.error __("Cannot Edit category") if r.error
me.refreshCVCat()
, "Edit category", { tree: (me.cvlist.get "data"), cat: cat }
, __("Edit category"), { tree: (me.cvlist.get "data"), cat: cat }
(@find "cv-cat-del").set "onbtclick", (e) ->
cat = me.cvlist.get "selectedItem"
@ -70,26 +70,26 @@ class Blogger extends this.OS.GUI.BaseApplication
(d) ->
return unless d
me.deleteCVCat cat
, "Delete cagegory" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{cat.name} ?" }
, __("Delete category") ,
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?", cat.name) }
(@find "cv-sec-add").set "onbtclick", (e) ->
cat = me.cvlist.get "selectedItem"
return me.notify "Please select a category" unless cat and cat.id isnt 0
return me.notify __("Please select a category") unless cat and cat.id isnt 0
me.openDialog "BloggerCVSectionDiaglog", (d) ->
d.cid = Number cat.id
d.start = Number d.start
d.end = Number d.end
d.publish = 1
me.cvsecdb.save d, (r) ->
return me.error "Cannot save section: #{r.error}" if r.error
return me.error __("Cannot save section: {0}", r.error) if r.error
me.CVSectionByCID Number(cat.id)
, "New section entry for #{cat.name}", null
, __("New section entry for {0}", cat.name), null
(@find "cv-sec-move").set "onbtclick", (e) ->
sec = (me.find "cv-sec-list").get "selected"
return me.notify "Please select a section to move" unless sec
return me.notify __("Please select a section to move") unless sec
me.openDialog "BloggerCategoryDialog", (d) ->
c =
@ -97,14 +97,14 @@ class Blogger extends this.OS.GUI.BaseApplication
cid: d.p.id
me.cvsecdb.save c, (r) ->
return me.error "Cannot move section" if r.error
return me.error __("Cannot move section") if r.error
me.CVSectionByCID(sec.cid)
(me.find "cv-sec-list").set "selected", -1
, "Move to", { tree: (me.cvlist.get "data"), selonly: true }
, __("Move to"), { tree: (me.cvlist.get "data"), selonly: true }
(@find "cv-sec-edit").set "onbtclick", (e) ->
sec = (me.find "cv-sec-list").get "selected"
return me.notify "Please select a section to edit" unless sec
return me.notify __("Please select a section to edit") unless sec
me.openDialog "BloggerCVSectionDiaglog", (d) ->
d.cid = Number sec.cid
@ -112,10 +112,10 @@ class Blogger extends this.OS.GUI.BaseApplication
d.end = Number d.end
d.publish = Number sec.publish
me.cvsecdb.save d, (r) ->
return me.error "Cannot save section: #{r.error}" if r.error
return me.error __("Cannot save section: {0}", r.error) if r.error
me.CVSectionByCID Number(sec.cid)
, "Modify section entry", sec
, __("Modify section entry"), sec
@editor = new SimpleMDE
element: me.find "markarea"
@ -124,14 +124,14 @@ class Blogger extends this.OS.GUI.BaseApplication
indentWithTabs: true
toolbar: [
{
name: "new",
name: __("New"),
className: "fa fa-file",
action: (e) ->
me.bloglist.set "selected", -1
me.clearEditor()
},
{
name: "save",
name: __("Save"),
className: "fa fa-save",
action: (e) ->
me.saveBlog()
@ -145,10 +145,10 @@ class Blogger extends this.OS.GUI.BaseApplication
action: (e) ->
me.openDialog "FileDiaLog", (d, n, p) ->
p.asFileHandler().publish (r) ->
return me.error "Cannot export file for embeding to text" if r.error
return me.error __("Cannot export file for embeding to text") if r.error
doc = me.editor.codemirror.getDoc()
doc.replaceSelection "![](#{me._api.handler.shared}/#{r.result})"
, "Select image file", { mimes: ["image/.*"] }
, __("Select image file"), { mimes: ["image/.*"] }
},
{
name:"Youtube",
@ -159,7 +159,7 @@ class Blogger extends this.OS.GUI.BaseApplication
}
"|",
{
name: "preview",
name: __("Preview"),
className: "fa fa-eye no-disable",
action: (e) ->
me.previewOn = !me.previewOn
@ -170,7 +170,7 @@ class Blogger extends this.OS.GUI.BaseApplication
sel = me.bloglist.get "selected"
return unless sel
me.blogdb.get Number(sel.id), (r) ->
me.error "Cannot fetch the entry content" if r.error
me.error __("Cannot fetch the entry content") if r.error
me.editor.value atob(r.result.content)
me.inputtags.value = r.result.tags
(me.find "blog-publish").set "swon", (if Number(r.result.publish) then true else false)
@ -179,12 +179,12 @@ class Blogger extends this.OS.GUI.BaseApplication
me.openDialog "YesNoDialog", (b) ->
return unless b
me.blogdb.delete e.item.item.id, (r) ->
return me.error "Cannot delete: #{r.error}" if r.error
return me.error __("Cannot delete: {0}", r.error) if r.error
me.bloglist.remove e.item.item, true
me.bloglist.set "selected", -1
me.clearEditor()
, "Delete a post" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete this post ?" }
, __("Delete a post") ,
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete this post ?") }
return false
@bindKey "CTRL-S", () ->
sel = me.tabbar.get "selidx"
@ -199,7 +199,7 @@ class Blogger extends this.OS.GUI.BaseApplication
when 0 #user info
@userdb.get null, (d) ->
return me.error "Cannot fetch user data" if d.error
return me.error __("Cannot fetch user data") if d.error
me.user = d.result[0]
inputs = me.select "[input-class='user-input']"
($ v).val me.user[v.name] for v in inputs
@ -212,11 +212,11 @@ class Blogger extends this.OS.GUI.BaseApplication
me = @
inputs = @select "[input-class='user-input']"
@user[v.name] = ($ v).val() for v in inputs
return @notify "Full name must be entered" if not @user.fullname or @user.fullname is ""
return @notify __("Full name must be entered") if not @user.fullname or @user.fullname is ""
#console.log @user
@userdb.save @user, (r) ->
return me.error "Cannot save user data" if r.error
return me.notify "User data updated"
return me.error __("Cannot save user data") if r.error
return me.notify __("User data updated")
# PORFOLIO TAB
@ -232,7 +232,7 @@ class Blogger extends this.OS.GUI.BaseApplication
@cvcatdb.find cnd, (d) ->
if d.error
me.cvlist.set "data", data
return me.notify "Cannot fetch CV categories"
return me.notify __("Cannot fetch CV categories")
me.fetchCVCat d.result, data, "0"
me.cvlist.set "data", data
#it = (me.cvlist.find "pid", "2")[0]
@ -258,10 +258,10 @@ class Blogger extends this.OS.GUI.BaseApplication
cond = ({ "=": { cid: v } } for v in ids)
# delete all content
@cvsecdb.delete { "or": cond }, (r) ->
return me.error "Cannot delete all content of: #{cat.name} [#{r.error}]" if r.error
return me.error __("Cannot delete all content of: {0} [{1}]", cat.name, r.error) if r.error
cond = ({ "=": { id: v } } for v in ids)
me.cvcatdb.delete { "or": cond }, (re) ->
return me.error "Cannot delete the category: #{cat.name} [#{re.error}]" if re.error
return me.error __("Cannot delete the category: {0} [{1}]", cat.name, re.error) if re.error
me.refreshCVCat()
CVSectionByCID: (cid) ->
@ -273,10 +273,10 @@ class Blogger extends this.OS.GUI.BaseApplication
order:
start: "DESC"
@cvsecdb.find cond, (d) ->
return me.notify "Section list is empty, please add one" if d.error
return me.notify __("Section list is empty, please add one") if d.error
v.text = v.title for v in d.result
items = []
$(me.find "cv-sec-status").html "Found #{d.result.length} sections"
$(me.find "cv-sec-status").html __("Found {0} sections", d.result.length)
for v in d.result
v.text = v.title
v.complex = true
@ -298,10 +298,10 @@ class Blogger extends this.OS.GUI.BaseApplication
me.openDialog "YesNoDialog", (b) ->
return unless b
me.cvsecdb.delete e.item.item.id, (r) ->
return me.error "Cannot delete the section: #{r.error}" if r.error
return me.error __("Cannot delete the section: {0}", r.error) if r.error
el.remove e.item.item, true
, "Delete section" ,
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{e.item.item.text} ?" }
, __("Delete section") ,
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?",e.item.item.text) }
return false
el.set "items", items
@ -312,8 +312,8 @@ class Blogger extends this.OS.GUI.BaseApplication
tags = @inputtags.value
content = @editor.value()
title = (new RegExp "^#+(.*)\n", "g").exec content
return @notify "Please insert a title in the text: beginning with heading" unless title and title.length is 2
return @notify "Please enter tags" if tags is ""
return @notify __("Please insert a title in the text: beginning with heading") unless title and title.length is 2
return @notify __("Please enter tags") if tags is ""
d = new Date()
data =
content: content.asBase64()
@ -328,7 +328,7 @@ class Blogger extends this.OS.GUI.BaseApplication
data.id = sel.id if sel
#save the data
@blogdb.save data, (r) ->
return me.error "Cannot save blog: #{r.error}" if r.error
return me.error __("Cannot save blog: {0}", r.error) if r.error
me.loadBlogs()
process: (text) ->
@ -377,15 +377,15 @@ class Blogger extends this.OS.GUI.BaseApplication
"utimestr"
]
@blogdb.find cond, (r) ->
return me.notify "No post found: #{r.error}" if r.error
return me.notify __("No post found: {0}", r.error) if r.error
console.log r.result
for v in r.result
v.text = v.title
v.complex = true
v.closable = true
v.detail = [
{ text: "Created: #{v.ctimestr}", class: "blog-dates" },
{ text: "Updated: #{v.utimestr}", class: "blog-dates" }]
{ text: __("Created: {0}", v.ctimestr), class: "blog-dates" },
{ text: __("Updated: {0}", v.utimestr), class: "blog-dates" }]
me.bloglist.set "items", r.result
if selidx isnt -1
me.bloglist.set "selected", selidx

View File

@ -5,26 +5,26 @@
<afx-hbox data-id="user-container" data-height="100%">
<afx-vbox>
<afx-hbox data-height = "30">
<afx-label data-width= "70" text = "Full name:"></afx-label>
<afx-label data-width= "70" text = "__(Full name)"></afx-label>
<input type = "text" name="fullname" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Address:" data-width= "70"></afx-label>
<afx-label text = "__(Address)" data-width= "70"></afx-label>
<input type = "text" name="address" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Phone:" data-width= "70"></afx-label>
<afx-label text = "__(Phone)" data-width= "70"></afx-label>
<input type = "text" name="Phone" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Email:" data-width= "70"></afx-label>
<afx-label text = "__(Email)" data-width= "70"></afx-label>
<input type = "text" name="email" input-class = "user-input"/>
</afx-hbox>
<afx-hbox data-height = "30">
<afx-label text = "Url:" data-width= "70"></afx-label>
<afx-label text = "__(Url)" data-width= "70"></afx-label>
<input type = "text" name="url" input-class = "user-input"/>
</afx-hbox>
<afx-label data-height = "30" text = "Short biblio:"/>
<afx-label data-height = "30" text = "__(Short biblio)"/>
<textarea name="shortbiblio" input-class = "user-input"/>
<afx-hbox data-height = "35">
<div></div>
@ -34,7 +34,7 @@
</afx-hbox>
<afx-hbox data-id="cv-container" data-height="100%">
<afx-vbox data-width="150" min-width="100">
<afx-label class = "cat-header" data-height = "23" text = "Categories" iconclass = "fa fa-bars"></afx-label>
<afx-label class = "cat-header" data-height = "23" text = "__(Categories)" iconclass = "fa fa-bars"></afx-label>
<afx-tree-view data-id = "cv-list" ></afx-tree-view>
<afx-hbox data-height="30" class = "cv-side-bar-btn">
<afx-button data-id = "cv-cat-add" data-width = "25" text = "" iconclass = "fa fa-plus-circle"></afx-button>
@ -60,7 +60,7 @@
<div data-id = "editor-container">
<textarea data-id="markarea" ></textarea>
</div>
<afx-label text = "Tags:" style="font-weight:bold;" data-height="25" ></afx-label>
<afx-label text = "__(Tags)" style="font-weight:bold;" data-height="25" ></afx-label>
<afx-hbox data-height="25">
<input type = "text" data-id = "input-tags" />
<div data-width="5"></div>

View File

@ -61,10 +61,10 @@ class CodeBlock extends this.OS.GUI.BaseApplication
menu = [{
text: "File",
child: [
{ text: "New", dataid: "#{@name}-New", shortcut: "A-N" },
{ text: "Open", dataid: "#{@name}-Open", shortcut: "A-O" },
{ text: "Save", dataid: "#{@name}-Save", shortcut: "C-S" },
{ text: "Save as", dataid: "#{@name}-Saveas", shortcut: "A-W" }
{ text: __("New"), dataid: "#{@name}-New", shortcut: "A-N" },
{ text: __("Open"), dataid: "#{@name}-Open", shortcut: "A-O" },
{ text: __("Save"), dataid: "#{@name}-Save", shortcut: "C-S" },
{ text: __("Save as"), dataid: "#{@name}-Saveas", shortcut: "A-W" }
],
onmenuselect: (e) -> me.actionFile e.item.data.dataid
}]

View File

@ -97,7 +97,7 @@ class PushNotification extends this.OS.GUI.BaseService
PushNotification.scheme = """
<afx-dummy>
<afx-overlay data-id = "notifyzone" width = "250">
<afx-button text = "Clear all" data-id = "btclear"></afx-button>
<afx-button text = "__(Clear all)" data-id = "btclear"></afx-button>
<afx-list-view data-id="notifylist"></afx-list-view>
</afx-overlay>
<afx-overlay data-id = "feedzone" width = "250">

View File

@ -7,17 +7,17 @@ class UserService extends this.OS.GUI.BaseService
me = @
@child = [
{
text: "About", dataid: "user-about",
text: __("About"), dataid: "user-about",
iconclass: "fa fa-user-circle-o"
},
{
text: "Logout", dataid: "sys-logout",
text: __("Logout"), dataid: "sys-logout",
iconclass: "fa fa-user-times"
}
]
@onmenuselect = (d) ->
return window.OS.exit() if d.item.data.dataid is "sys-logout"
me.notify "This feature is not implemented yet"
me.notify __("This feature is not implemented yet")
awake: (e) ->
cleanup: (evt) ->

View File

@ -7,7 +7,7 @@
</afx-vbox>
<afx-resizer data-width = "5" ></afx-resizer>
<afx-vbox>
<afx-button data-height="30" text="Read more" iconclass="fa fa-camera-retro fa-lg" id="button"></afx-button>
<afx-button data-height="30" text="__(Read more)" iconclass="fa fa-camera-retro fa-lg" id="button"></afx-button>
<afx-switch enable= true data-height="30"></afx-switch>
<afx-calendar-view></afx-calendar-view>
<afx-resizer data-height = "5" ></afx-resizer>

View File

@ -124,7 +124,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
app.path.asFileHandler().remove (r) ->
return me.error "Cannot uninstall package: #{r.error}" if r.error
me.notify "Package uninstalled"
me.systemsetting.system.packages[name] = undefined
delete me.systemsetting.system.packages[name]
me._gui.refreshSystemMenu()
me.appDetail sel
, "Uninstall" ,