diff --git a/app/assets/javascripts/app/lib/app_post/i18n.coffee b/app/assets/javascripts/app/lib/app_post/i18n.coffee index f9f6fb251..ba7ae9a5d 100644 --- a/app/assets/javascripts/app/lib/app_post/i18n.coffee +++ b/app/assets/javascripts/app/lib/app_post/i18n.coffee @@ -288,9 +288,11 @@ class _i18nSingleton extends Spine.Module @_notTranslated[locale][key] = true date: (time, offset) => + return time if !time @convert(time, offset, @mapTime['date'] || @dateFormat) timestamp: (time, offset) => + return time if !time @convert(time, offset, @mapTime['timestamp'] || @timestampFormat) convert: (time, offset, format) -> diff --git a/public/assets/tests/core.js b/public/assets/tests/core.js index 2cfcbc0ab..3c9401487 100644 --- a/public/assets/tests/core.js +++ b/public/assets/tests/core.js @@ -312,6 +312,27 @@ test('i18n', function() { var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset); equal(timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly') + timestamp = App.i18n.translateTimestamp('', offset); + equal(timestamp, '', 'de-de - timestamp translated correctly') + + timestamp = App.i18n.translateTimestamp(null, offset); + equal(timestamp, null, 'de-de - timestamp translated correctly') + + timestamp = App.i18n.translateTimestamp(undefined, offset); + equal(timestamp, undefined, 'de-de - timestamp translated correctly') + + var date = App.i18n.translateDate('2012-11-06', 0) + equal(date, '06.11.2012', 'de-de - date translated correctly') + + date = App.i18n.translateDate('', 0) + equal(date, '', 'de-de - date translated correctly') + + date = App.i18n.translateDate(null, 0) + equal(date, null, 'de-de - date translated correctly') + + date = App.i18n.translateDate(undefined, 0) + equal(date, undefined, 'de-de - date translated correctly') + // en App.i18n.set('en-us') translated = App.i18n.translateContent('yes') @@ -368,6 +389,27 @@ test('i18n', function() { timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset) equal(timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly') + timestamp = App.i18n.translateTimestamp('', offset); + equal(timestamp, '', 'en - timestamp translated correctly') + + timestamp = App.i18n.translateTimestamp(null, offset); + equal(timestamp, null, 'en - timestamp translated correctly') + + timestamp = App.i18n.translateTimestamp(undefined, offset); + equal(timestamp, undefined, 'en - timestamp translated correctly') + + date = App.i18n.translateDate('2012-11-06', 0) + equal(date, '11/06/2012', 'en - date translated correctly') + + date = App.i18n.translateDate('', 0) + equal(date, '', 'en - date translated correctly') + + date = App.i18n.translateDate(null, 0) + equal(date, null, 'en - date translated correctly') + + date = App.i18n.translateDate(undefined, 0) + equal(date, undefined, 'en - date translated correctly') + // locale alias test // de App.i18n.set('de')