HelloZeroNet / HelloZeroNet/ZeroNet
ZeroNet's --debug mode Automatic CoffeeScript -> JavaScript conversion not friendly of i18n
- Lingua principale
- JavaScript
- Stelle
- 18.8k
- Fork
- 2.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
coffee script not friendly of i18n, like that:
```
class Time
since: (time) ->
now = +(new Date) / 1000
secs = now - time
if secs < 60
back = "Just now"
else if secs < 60 * 60
back = "#{Math.round(secs / 60)} minutes ago"
else if secs < 60 * 60 * 24
back = "#{Math.round(secs / 60 / 60)} hours ago"
else if secs < 60 * 60 * 24 * 3
back = "#{Math.round(secs / 60 / 60 / 24)} days ago"
else
back = "on " + @date(time)
back = back.replace(/1 ([a-z]+)s/, "1 $1") # 1 days ago fix
return back
date: (timestamp, format = "short") ->
parts = new Date(timestamp * 1000)
if format == "short"
display = (parts.getFullYear() + "nian" + String(parts.getMonth() + 1) + "yue" + parts.getDay() + "ri")
else
display = parts.toTimeString()
return display
timestamp: (date = "") ->
if date == "now" or date == ""
return parseInt(+(new Date) / 1000)
else
return parseInt(Date.parse(date) / 1000)
# Get elistamated read time for post
readtime: (text) ->
chars = text.length
if chars > 1500
return parseInt(chars / 1500) + " min read"
else
return "less than 1 min read"
window.Time = new Time
```
success

but if I change it to Chinese...BOOM.
```
class Time
since: (time) ->
now = +(new Date) / 1000
secs = now - time
if secs < 60
back = "刚才"
else if secs < 60 * 60
back = "#{Math.round(secs / 60)} 分钟前"
else if secs < 60 * 60 * 24
back = "#{Math.round(secs / 60 / 60)} 小时前"
else if secs < 60 * 60 * 24 * 3
back = "#{Math.round(secs / 60 / 60 / 24)} 天之前"
else
back = "on " + @date(time)
back = back.replace(/1 ([a-z]+)s/, "1 $1") # 1 days ago fix
return back
date: (timestamp, format = "short") ->
parts = new Date(timestamp * 1000)
if format == "short"
display = (parts.getFullYear() + "年" + String(parts.getMonth() + 1) + "月" + parts.getDay() + "日")
else
display = parts.toTimeString()
return display
timestamp: (date = "") ->
if date == "now" or date == ""
return parseInt(+(new Date) / 1000)
else
return parseInt(Date.parse(date) / 1000)
# Get elistamated read time for post
readtime: (text) ->
chars = text.length
if chars > 1500
return parseInt(chars / 1500) + " min read"
else
return "less than 1 min read"
window.Time = new Time
```

Um....How to slove it? or ZeroBundle should upgrade Coffee Script?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.