Improved error handling.

This commit is contained in:
Martin Edenhofer 2014-08-03 23:07:51 +02:00
parent af0ead3822
commit ee8a4333fd

View file

@ -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