Sha256: 0ef84a943dc62b8cd802eb8c9f95cc9aecb1f3303f24278e212bac0d5b449296

Contents?: true

Size: 942 Bytes

Versions: 1

Compression:

Stored size: 942 Bytes

Contents

require 'rubygems'
require 'yaml'

module Jekyll
  module LanguagePlugin
    module Loaders
      class BuiltinDataLoader < BaseLoader
        attr_reader :data

        def initialize(site)
          super
          @data = Hash.new
        end

        def loaded?(language)
          @data.has_key?(language)
        end

        def load(language)
          return true if loaded?(language)

          file = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'data', 'lang', "#{language}.yml"))
          return false unless File.file?(file)

          !!@data.merge!(YAML.load_file(file));
        end

        def get(key, language)
          return nil unless loaded?(language)

          traverse_hash(@data, resolve_dot_notation([language, key]))
        end
      end
    end
  end
end

$stdout.puts("Registering!")
Jekyll::LanguagePlugin.register_loader(Jekyll::LanguagePlugin::Loaders::BuiltinDataLoader)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.2.3 lib/jekyll/language-plugin/loaders/builtin_data_loader.rb