add FormatedString class, automatically translate to new locale when locale is set

This commit is contained in:
Xuan Sang LE
2018-03-10 20:42:09 +01:00
parent 88cf90ae50
commit 6367c321da
12 changed files with 75 additions and 39 deletions

View File

@ -58,7 +58,7 @@ class NotePad extends this.OS.GUI.BaseApplication
stup = (e) ->
c = me.editor.session.selection.getCursor()
l = me.editor.session.getLength()
$(stat).html __("Row {0}, col {1}, lines: {2}", c.row, c.column, l)
stat.set "text", __("Row {0}, col {1}, lines: {2}", c.row, c.column, l)
stup(0)
@.editor.getSession().selection.on "changeCursor", (e) -> stup(e)
@editormux = false
@ -133,6 +133,7 @@ class NotePad extends this.OS.GUI.BaseApplication
me = @
file = @fileview.get "selectedFile"
dir = if file then file.path.asFileHandler() else (@fileview.get "path").asFileHandler()
console.log dir
dir = dir.parent().asFileHandler() if file and file.type isnt "dir"
switch e.item.data.dataid
@ -141,7 +142,7 @@ class NotePad extends this.OS.GUI.BaseApplication
(d) ->
dir.mk d, (r) ->
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
, __("New folder")
, "__(New folder)"
when "#{@name}-mkf"
@openDialog "PromptDialog",
@ -149,7 +150,7 @@ class NotePad extends this.OS.GUI.BaseApplication
fp = "#{dir.path}/#{d}".asFileHandler()
fp.write "", (r) ->
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
, __("New file")
, "__(New file)"
when "#{@name}-rm"
return unless file
@openDialog "YesNoDialog",
@ -158,7 +159,7 @@ class NotePad extends this.OS.GUI.BaseApplication
file.path.asFileHandler()
.remove (r) ->
me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
, __("Delete") ,
, "__(Delete)" ,
{ iconclass: "fa fa-question-circle", text: __("Do you really want to delete: {0}?", file.filename) }
when "#{@name}-refresh"
@.chdir ( @fileview.get "path" )
@ -267,12 +268,12 @@ class NotePad extends this.OS.GUI.BaseApplication
me.tabarea.replaceItem me.currfile, file, false
me.currfile = file
me.save me.currfile
, __("Save as"), { file: me.currfile }
, "__(Save as)", { file: me.currfile }
switch e
when "#{@name}-Open"
@openDialog "FileDiaLog", ( d, f ) ->
me.open "#{d}/#{f}".asFileHandler()
, __("Open file")
, "__(Open file)"
when "#{@name}-Save"
@currfile.cache = @editor.getValue()
return @save @currfile if @currfile.basename
@ -292,7 +293,7 @@ class NotePad extends this.OS.GUI.BaseApplication
if d
v.dirty = false for v in dirties
me.quit()
, __("Quit"), { text: __("Ignore all {0} unsaved files ?", dirties.length) }
, "__(Quit)", { text: __("Ignore all {0} unsaved files ?", dirties.length) }
NotePad.singleton = false
NotePad.dependencies = [

View File

@ -11,7 +11,7 @@ afx-app-window[data-id="notepad"] afx-resizer{
background-color: transparent;
border-right: 1px solid #a6a6a6;
}
afx-app-window[data-id="notepad"] span[data-id="editorstat"]{
afx-app-window[data-id="notepad"] afx-label[data-id="editorstat"]{
padding:5px;
display: inline-block;
}

View File

@ -9,7 +9,7 @@
<afx-tab-container data-id="tabarea" data-height="26" closable = true></afx-tab-container>
<div data-id="datarea"></div>
<afx-hbox data-height="30" data-id="bottom-vbox">
<div ><span data-id = "editorstat"></span></div>
<afx-label data-id="editorstat"></afx-label>
<afx-list-view data-width="160" data-id = "themelist" dropdown = "true" width="135"></afx-list-view>
<afx-list-view data-width="125" data-id = "modelist" dropdown = "true" width="100"></afx-list-view>