Code cleanup.
This commit is contained in:
parent
bf476d74ed
commit
68f608d9f9
1 changed files with 14 additions and 9 deletions
|
@ -7,12 +7,17 @@ class App.i18n
|
|||
@translateContent: ( string, args... ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.translate_content( string, args )
|
||||
_instance.translateContent( string, args )
|
||||
|
||||
@translatePlain: ( string, args... ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.translatePlain( string, args )
|
||||
|
||||
@translateInline: ( string, args... ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.translate_inline( string, args )
|
||||
_instance.translateInline( string, args )
|
||||
|
||||
@translateTimestamp: ( args ) ->
|
||||
if _instance == undefined
|
||||
|
@ -116,11 +121,11 @@ class _Singleton extends Spine.Module
|
|||
App.Translation.refresh( { id: object[0], source: object[1], target: object[2], locale: @locale } )
|
||||
)
|
||||
|
||||
translate_inline: ( string, args... ) =>
|
||||
@translate( string, args... )
|
||||
translateInline: ( string, args... ) =>
|
||||
@escape( @translate( string, args... ) )
|
||||
|
||||
translate_content: ( string, args... ) =>
|
||||
translated = @translate( string, args... )
|
||||
translateContent: ( string, args... ) =>
|
||||
translated = @escape( @translate( string, args... ) )
|
||||
# replace = '<span class="translation" contenteditable="true" data-text="' + @escape(string) + '">' + translated + '<span class="icon-edit"></span>'
|
||||
if App.Config.get( 'Translation' )
|
||||
replace = '<span class="translation" contenteditable="true" data-text="' + @escape(string) + '">' + translated + ''
|
||||
|
@ -130,6 +135,9 @@ class _Singleton extends Spine.Module
|
|||
else
|
||||
translated
|
||||
|
||||
translatePlain: ( string, args... ) =>
|
||||
@translate( string, args... )
|
||||
|
||||
translate: ( string, args... ) =>
|
||||
|
||||
# return '' on undefined
|
||||
|
@ -147,9 +155,6 @@ class _Singleton extends Spine.Module
|
|||
for arg in args
|
||||
translated = translated.replace(/%s/, arg)
|
||||
|
||||
# escape
|
||||
translated = @escape(translated)
|
||||
|
||||
@log 'i18n', 'debug', 'translate', string, args, translated
|
||||
|
||||
# return translated string
|
||||
|
|
Loading…
Reference in a new issue