Class: Jekyll::LocalizeTag

Inherits:
Liquid::Tag
  • Object
show all
Includes:
FastGettext::Translation
Defined in:
lib/jekyll/gettext/plugin.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, key, tokens) ⇒ LocalizeTag

Returns a new instance of LocalizeTag.



61
62
63
64
# File 'lib/jekyll/gettext/plugin.rb', line 61

def initialize(tag_name, key, tokens)
  super
  @key = key.strip
end

Instance Method Details

#render(context) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/jekyll/gettext/plugin.rb', line 66

def render(context)
  if "#{context[@key]}" != "" # check for page variable
    key = "#{context[@key]}"
  else
    key = @key
  end
  candidate = _(key)

  # binding.pry

  lang = context.registers[:site].config['lang']

  if candidate == key and lang != 'en'
    puts "Missing i18n key: " + lang + ":" + key
    "*" + lang + ":" + key + "*"
  end
  candidate
end