Sha256: d7cb750e788daf27052022e0a7b7d5ae6a6d67029ee73b3af39010f6c20e5ce7

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

module Jekyll
  class LanguagePage < Page
    alias_method :template_orig, :template
    alias_method :url_placeholders_orig, :url_placeholders

    def language
      return nil if data.nil? || data['language'].nil?
      data['language']
    end

    def languages
      return nil if data.nil? || data['languages'].nil?
      data['languages']
    end

    def subset
      return nil if data.nil? || data['subset'].nil?
      data['subset']
    end

    def template
      return "/:language" + template_orig if !language.nil?
      template_orig
    end

    def url_placeholders
      result = url_placeholders_orig.merge!({
        language: language,
        subset: subset
      })

      if !language.nil? && !subset.nil?
        @language_data ||= LanguagePlugin::LanguageData.new(@site, language)

        data = @language_data.get(subset).reject{ |k, v| v.is_a?(Enumerable) }
        result.merge!(Hash[data.map{ |k, v| ["t.#{k}", v] }])
      end

      result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.1.8 lib/jekyll/language_page.rb