Showing the changes to assets/javascripts (1 of 1 file). Show all
Unified · Split
| @@ -0,0 +1,17 @@ | |||
| 1 | class @I18n | ||
| 2 | constructor: (@data, lang = 'en') -> | ||
| 3 | @setLanguage lang | ||
| 4 | |||
| 5 | setLanguage: (lang) -> | ||
| 6 | return false unless @data[lang] | ||
| 7 | @lang = lang | ||
| 8 | true | ||
| 9 | |||
| 10 | _: (key, substitution) -> | ||
| 11 | str = @data[@lang][key] | ||
| 12 | return unless str? | ||
| 13 | |||
| 14 | if substitution? | ||
| 15 | for key in Object.keys(substitution) | ||
| 16 | str = str.replace("{#{key}}", substitution[key]) | ||
| 17 | str | ||