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... ) =>
# type convertation
if typeof string isnt 'string'
if string && string.toString
string = string.toString()
# return '' on undefined
if typeof string is 'boolean'
string = string.toString()
return '' if string is undefined
return '' if string is ''
# return translation
if @map[string] isnt undefined
@_translated = true
translated = @map[string]
translated = @map[string]
else
@_translated = false
translated = string
translated = string
# search %s
for arg in args