mirror of https://github.com/freeCodeCamp/devdocs
parent
d48396de57
commit
3bd91c9327
@ -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…
Reference in new issue