Create I18n helper

i18n
Jed Fox 7 years ago committed by GitHub
parent d48396de57
commit 3bd91c9327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,17 @@
class @I18n
constructor: (@data, lang = 'en') ->
@setLanguage lang
setLanguage: (lang) ->
return false unless @data[lang]
@lang = lang
true
_: (key, substitution) ->
str = @data[@lang][key]
return unless str?
if substitution?
for key in Object.keys(substitution)
str = str.replace("{#{key}}", substitution[key])
str
Loading…
Cancel
Save