Small code layout improvement to prevent not necessary translations.

This commit is contained in:
Martin Edenhofer 2016-02-24 06:26:14 +01:00
parent 84894944a7
commit 1aae6eacb5

View file

@ -38,12 +38,13 @@ class App.PrettyDate
if diff >= 86400 if diff >= 86400
count++ count++
unit = Math.floor( ( diff / 86400 ) ) unit = Math.floor( ( diff / 86400 ) )
day = App.i18n.translateInline('d')
if long if long
if unit > 1 || unit is 0 if unit > 1 || unit is 0
day = App.i18n.translateInline('days') day = App.i18n.translateInline('days')
else else
day = App.i18n.translateInline('day') day = App.i18n.translateInline('day')
else
day = App.i18n.translateInline('d')
string = unit + ' ' + day string = unit + ' ' + day
diff = diff - ( unit * 86400 ) diff = diff - ( unit * 86400 )
if unit >= 9 || diff < 3600 || count is 2 if unit >= 9 || diff < 3600 || count is 2
@ -59,12 +60,13 @@ class App.PrettyDate
if diff >= 3600 if diff >= 3600
count++ count++
unit = Math.floor( ( diff / 3600 ) % 24 ) unit = Math.floor( ( diff / 3600 ) % 24 )
hour = App.i18n.translateInline('h')
if long if long
if unit > 1 || unit is 0 if unit > 1 || unit is 0
hour = App.i18n.translateInline('hours') hour = App.i18n.translateInline('hours')
else else
hour = App.i18n.translateInline('hour') hour = App.i18n.translateInline('hour')
else
hour = App.i18n.translateInline('h')
if string isnt '' if string isnt ''
string = string + ' ' string = string + ' '
string = string + unit + ' ' + hour string = string + unit + ' ' + hour
@ -80,12 +82,13 @@ class App.PrettyDate
# minutes # minutes
unit = Math.floor( ( diff / 60 ) % 60 ) unit = Math.floor( ( diff / 60 ) % 60 )
minute = App.i18n.translateInline('m')
if long if long
if unit > 1 || unit is 0 if unit > 1 || unit is 0
minute = App.i18n.translateInline('minutes') minute = App.i18n.translateInline('minutes')
else else
minute = App.i18n.translateInline('minute') minute = App.i18n.translateInline('minute')
else
minute = App.i18n.translateInline('m')
if string isnt '' if string isnt ''
string = string + ' ' string = string + ' '
string = string + unit + ' ' + minute string = string + unit + ' ' + minute