jekyll-language-plugin 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09d08bc0bd9ace9e9ed14474e8f57ce0298e6779
4
- data.tar.gz: a6ab1ecd54e36a03a986af23d5ee9b0f16f35af5
3
+ metadata.gz: b0a05d1d865dc59d54dada24d41de3c9d5d615de
4
+ data.tar.gz: 002e66f66fa993f0abbe721e71a31357562f5cb7
5
5
  SHA512:
6
- metadata.gz: 91724843ebb69d1ad67e45b3ca8937f50b2cbb2bf5f8c2f1c1caf0803c8d86ddf6d959656b293bfa755f57354b58678ed3010a9baf340270fc8cf0b657e9d26e
7
- data.tar.gz: 97201c70f08003ea0426e0009202d1153660a651f5a87535dc0a1c7fc18ed7c88ec157018d6a980bd6e308f2791b7b96aa68b35f53468abe257af57988bfc7ef
6
+ metadata.gz: 6410a6d6c6dce3fa4ec4e60bdf6492b4d8979a30930977144171c88734431da6a2fe1d10b85f6addd8ea3ea0005247fdda51dc0eea6c07886db044cfced54cc4
7
+ data.tar.gz: ae6919a539b02a056908dbb88bb7c28df9bd3f33457feb1ae4ca8993ffb88ead15b1c8c72adf9613a3ff852fba720638f600b9f44a51e37ef1047d35ea5aa4fb
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module Tags
3
3
  class LanguageIncludeTag < IncludeTag
4
4
  def tag_includes_dir(context)
5
- context.registers[:site].config['language_includes_dir'].freeze
5
+ (context.registers[:site].config['language_includes_dir'].to_s || '_i18n').freeze
6
6
  end
7
7
 
8
8
  def page_language(context)
@@ -4,7 +4,7 @@ module JekyllLanguagePlugin
4
4
  translation = JekyllLanguagePlugin::LiquidContext.get_language_data(context, 'date')
5
5
 
6
6
  # validate language translation
7
- return nil if translation.nil? ||
7
+ raise JekyllLanguagePlugin::PluginError.new('Localized date is missing translation.') if translation.nil? ||
8
8
  !['abbr_daynames', 'daynames', 'abbr_monthnames', 'monthnames'].all? {|s| translation.key?(s) && translation[s].is_a?(Array) } ||
9
9
  translation['abbr_daynames'].size < 7 || translation['daynames'].size < 7 ||
10
10
  translation['abbr_monthnames'].size < 12 || translation['monthnames'].size < 12
@@ -25,7 +25,7 @@ module JekyllLanguagePlugin
25
25
  when 'b'; translation['abbr_monthnames'][self.mon-1]
26
26
  when 'B'; translation['monthnames'][self.mon-1]
27
27
  else
28
- raise "Date#strftime: InputError"
28
+ raise JekyllLanguagePlugin::PluginError.new('Internal error.')
29
29
  end
30
30
  })
31
31
  if defined? @@encoding_converter
@@ -2,16 +2,21 @@ module JekyllLanguagePlugin
2
2
  module LiquidContext
3
3
  def self.get_language_data(context, keys = nil)
4
4
  site = context.registers[:site]
5
- language_data = site.config['language_data']
5
+ language_data = site.config['language_data'].to_s || 'data.lang.%%'
6
+
6
7
  page_language = context.registers[:page]['language']
7
- return nil if language_data.to_s.empty? || page_language.to_s.empty?
8
+ return nil if page_language.to_s.empty?
8
9
 
9
10
  keys2 = language_data.gsub("%%", page_language).split('.')
10
11
  language_data = site.send(keys2.shift)
11
12
  language_data = self.traverse_hash(language_data, keys2)
13
+ raise JekyllLanguagePlugin::PluginError.new('Invalid language data configuration.') if language_data.nil?
12
14
 
13
15
  return language_data if keys.to_s.empty? # can also return nil
14
- self.traverse_hash(language_data, keys)
16
+
17
+ language_data = self.traverse_hash(language_data, keys)
18
+ raise JekyllLanguagePlugin::PluginError.new("Language subset #{keys.to_s} not found.") if language_data.nil?
19
+ language_data
15
20
  end
16
21
 
17
22
  def self.get_language_string(context, key)
@@ -24,8 +29,8 @@ module JekyllLanguagePlugin
24
29
  !(str = traverse_hash(data, key)).to_s.empty?
25
30
  return str
26
31
  end
27
-
28
- ""
32
+
33
+ raise JekyllLanguagePlugin::PluginError.new("Language string #{key} not found.")
29
34
  end
30
35
 
31
36
  def self.traverse_hash(hash, keys)
@@ -0,0 +1,4 @@
1
+ module JekyllLanguagePlugin
2
+ class PluginError < RuntimeError
3
+ end
4
+ end
@@ -1,4 +1,5 @@
1
1
  # require all files in jekyll-language-plugin subdirectory
2
+ require 'jekyll-language-plugin/plugin_exception.rb'
2
3
  require 'jekyll-language-plugin/liquid_context.rb'
3
4
  require 'jekyll-language-plugin/date_localizer.rb'
4
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-language-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Wochnik
@@ -84,6 +84,7 @@ files:
84
84
  - lib/jekyll/tags/language_include.rb
85
85
  - lib/jekyll-language-plugin/date_localizer.rb
86
86
  - lib/jekyll-language-plugin/liquid_context.rb
87
+ - lib/jekyll-language-plugin/plugin_exception.rb
87
88
  - README.md
88
89
  - LICENSE.md
89
90
  homepage: https://github.com/vwochnik/jekyll-language-plugin