Class: Jekyll::TranslateTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-i18n.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, text, tokens) ⇒ TranslateTag

Returns a new instance of TranslateTag


14
15
16
17
# File 'lib/jekyll-i18n.rb', line 14

def initialize(tag_name, text, tokens)
	super
	@text = text
end

Instance Method Details

#render(context) ⇒ Object

Gets a translation of a key according to the page.lang


20
21
22
23
24
# File 'lib/jekyll-i18n.rb', line 20

def render(context)
	# See https://www.iana.org/assignments/language-subtag-registry for full list of tags
	I18n.locale = context.registers[:page]['lang'].intern
	I18n.t(@text.strip)
end