class Jekyll::AttendeasePlugin::TranslateTag

Public Class Methods

new(tag_name, params, tokens) click to toggle source
Calls superclass method
# File lib/jekyll/attendease_plugin/tags.rb, line 46
def initialize(tag_name, params, tokens)
  super
  args = split_params(params)
  @key = args.shift
  @options = { 't_size' => 0 }
  if args.length
    args.each do |a|
      match = a.match(/^(.+):\s*(.+)$/)
      @options[match[1]] = match[2].to_i if match
    end
  end
end

Public Instance Methods

render(context) click to toggle source
# File lib/jekyll/attendease_plugin/tags.rb, line 63
def render(context)
  I18n::Backend::Simple.include(I18n::Backend::Pluralization)
  I18n.enforce_available_locales = false
  i18n_path = File.join(context.registers[:site].config['attendease_source'], '_attendease', 'data', 'lingo.yml')
  I18n.load_path << i18n_path unless I18n.load_path.include?(i18n_path)
  I18n.locale = context.registers[:page]['lang'] || context.registers[:site].config['attendease']['locale'] || context.registers[:site].config['attendease']['lang'] || :en
  I18n.t(@key, :count => @options['t_size'])
end
split_params(params) click to toggle source
# File lib/jekyll/attendease_plugin/tags.rb, line 59
def split_params(params)
  params.split(",").map(&:strip)
end