HelloZeroNet / HelloZeroNet/ZeroNet

ZeroNet's --debug mode Automatic CoffeeScript -> JavaScript conversion not friendly of i18n

Offen
#713 11 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
18.8k
Forks
2.3k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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
![image](https://cloud.githubusercontent.com/assets/15062548/21390661/005675ca-c7c3-11e6-8d60-f3da5428dade.png)
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

```
![image](https://cloud.githubusercontent.com/assets/15062548/21390739/59740c8a-c7c3-11e6-836b-94c9c73e3bdc.png)
Um....How to slove it? or ZeroBundle should upgrade Coffee Script?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.