Improved error handling.
This commit is contained in:
parent
af0ead3822
commit
ee8a4333fd
1 changed files with 7 additions and 4 deletions
|
@ -143,19 +143,22 @@ class _i18nSingleton extends Spine.Module
|
||||||
|
|
||||||
translate: ( string, args... ) =>
|
translate: ( string, args... ) =>
|
||||||
|
|
||||||
|
# type convertation
|
||||||
|
if typeof string isnt 'string'
|
||||||
|
if string && string.toString
|
||||||
|
string = string.toString()
|
||||||
|
|
||||||
# return '' on undefined
|
# return '' on undefined
|
||||||
if typeof string is 'boolean'
|
|
||||||
string = string.toString()
|
|
||||||
return '' if string is undefined
|
return '' if string is undefined
|
||||||
return '' if string is ''
|
return '' if string is ''
|
||||||
|
|
||||||
# return translation
|
# return translation
|
||||||
if @map[string] isnt undefined
|
if @map[string] isnt undefined
|
||||||
@_translated = true
|
@_translated = true
|
||||||
translated = @map[string]
|
translated = @map[string]
|
||||||
else
|
else
|
||||||
@_translated = false
|
@_translated = false
|
||||||
translated = string
|
translated = string
|
||||||
|
|
||||||
# search %s
|
# search %s
|
||||||
for arg in args
|
for arg in args
|
||||||
|
|
Loading…
Reference in a new issue