Skip to content

Instantly share code, notes, and snippets.

View shesek's full-sized avatar

Nadav Ivgi shesek

View GitHub Profile
@shesek
shesek / i18n.coffee
Created November 14, 2011 22:38 — forked from madrobby/i18n.coffee
i18n with CoffeeScript
# Works with `global` instead of `window` when available (nodejs environment), no Backbone dependency,
# no ev[ai]l for rendering variables and a shorter `{...}` syntax.
(global or window).t = (id, vars = {}) ->
(i18n[__locale][id] or i18n.en[id] or "(?) #{id}")
.replace /\{(\w+)\}/g, (a, k) -> vars[k] or "?#{k}"
###
i18n=