mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
371 B
18 lines
371 B
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
|