class Jekyll::LocalizeTag
Public Class Methods
new(tag_name, key, tokens)
click to toggle source
Calls superclass method
# File lib/jekyll/gettext/plugin.rb, line 182 def initialize(tag_name, key, tokens) super @key = key.strip end
Public Instance Methods
add_localization_to_dependency(site, language, path)
click to toggle source
# File lib/jekyll/gettext/plugin.rb, line 207 def add_localization_to_dependency(site, language, path) po_file = site.pot_localization_plugin.po_file(language) site.regenerator.add_dependency( site.in_source_dir(path), po_file ) end
render(context)
click to toggle source
# File lib/jekyll/gettext/plugin.rb, line 187 def render(context) site = context.registers[:site] page = context.registers[:page] language = page["language"] if language.nil? default_language = page["default_language"].to_s raise ("Missing language! Either put 'language: " + default_language + "' or 'translate: true' into the header") end add_localization_to_dependency(site, language, page["path"]) if page.key?("path") FastGettext.locale = language candidate = _(@key) if candidate == "" candidate = @key end candidate end