Sha256: 43ad62fba9e1c0ed3695a89dd622c1500ce309a68201b03c05b1cc1eff623c1f

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

module Jekyll
  module Figure
    module Utils

      class I18n
        @figure_i18n = {'en' => "Figure",
                        'de' => "Abbildung",
                        'sv' => "Figur",
                        'fr' => "Figure"}
        def self.figure(lang)
          return @figure_i18n[lang] if @figure_i18n.key?(lang)
          @figure_i18n['en']
        end
      end

      def lang
        return @context.registers[:page]["lang"].to_s if @context.registers[:page].key?("lang")
        "en".to_s
      end

      def figure
        return @context.registers[:page]["figure"].to_s if @context.registers[:page].key?("figure")
        I18n.figure(lang)
      end
      
      def print_figure_counter(label)
        label.gsub!(/\s/, '')
        @context.registers[:page]["figure_labels"] ||= {}
        
        if @context.registers[:page]["figure_labels"].key?(label)
          value = @context.registers[:page]["figure_labels"][label]
        else
          value = @context.registers[:page]["figure_labels"].length + 1
          @context.registers[:page]["figure_labels"][label] = value
        end
        "<em>" + figure + " " + value.to_s + ":</em> "
      end

      def print_reference(label)
        label.gsub!(/\s/, '')
        "<a href=\"\##{label.to_s}\">" + figure.downcase + " " +
          @context.registers[:page]["figure_labels"][label.to_s].to_s +
        "</a>"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-figure-0.2.0 lib/utils.rb