Class: Jekyll::AttendeasePlugin::TranslateTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::AttendeasePlugin::TranslateTag
- Defined in:
- lib/jekyll/attendease_plugin/tags.rb
Instance Method Summary collapse
-
#initialize(tag_name, params, tokens) ⇒ TranslateTag
constructor
A new instance of TranslateTag.
- #render(context) ⇒ Object
- #split_params(params) ⇒ Object
Constructor Details
#initialize(tag_name, params, tokens) ⇒ TranslateTag
Returns a new instance of TranslateTag.
46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 |
Instance Method Details
#render(context) ⇒ Object
63 64 65 66 67 68 69 70 |
# 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['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) ⇒ Object
59 60 61 |
# File 'lib/jekyll/attendease_plugin/tags.rb', line 59 def split_params(params) params.split(",").map(&:strip) end |