jekyll-translations 0.1.0 → 1.0.0

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: 193b4cab49b666311eab24cb81b1ae8c304b4f5b
4
- data.tar.gz: acce204fa83860d1ea53d12e49240e1754f8f0b5
3
+ metadata.gz: 8f072fa67b86fd28d693032f390a3c9328364dbe
4
+ data.tar.gz: 18490b493a89dbec2c72be8f7fdb8521826fb724
5
5
  SHA512:
6
- metadata.gz: 06fb12b5f0022d131bca1a2771db68a289c616439e878dcdf0f45f1f60b0d423a5e3ecc1c856de7a7b134060496cfd647715c60259d8125c849e316fcf2b1cd8
7
- data.tar.gz: d3e94990bce50e346ce0ad1d6b1cd7f7d9d26e5e6354fc3207ea7a547391ff9c25dc62885b00a6177cabe0a198f264388c80bab3f5a4eeaacb8e2c36fb60cfe2
6
+ metadata.gz: 4b8c37a27179ce8a0800ff46b66a9e9441fb7a1248dfa1025daa8772aa54614245720c1096f8054a13f217124bb3b3c3305c22e7b248a76a4e872c946658f5d6
7
+ data.tar.gz: eaba7423c0883035b99fff0abd9a60f68b56bd6c40023f3a544b2a820d0e9aba4ca55cd668b7753b40cdd3db127008c96f12e97af08e1925fd9a217d0323b9a2
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Jekyll::Translations
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/translations`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is a Jekyll plugin to manage translations from a variety of sources, including AWS S3 and PO Editor.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,14 +20,4 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-translations.
23
+ If added correctly to the Gemfile, this plugin should work as a seamless replacement to local versions of the plugin that we have been using on our frontend Jekyll sites.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "jekyll-translations"
3
- spec.version = "0.1.0"
3
+ spec.version = "1.0.0"
4
4
  spec.authors = ["Jordan Dalton"]
5
5
  spec.email = ["jordan.dalton@researchsquare.com"]
6
6
  spec.require_paths = ["lib"]
@@ -5,9 +5,10 @@ module Jekyll
5
5
  module Translations
6
6
  class Generator < Jekyll::Generator
7
7
  def generate(site)
8
- translation_source = site.config['translations']['source']
8
+ translation_sources = site.config['translations']['sources']
9
9
 
10
- site.data['translations'] = JSON.parse(open(translation_source).read)
10
+ site.data['translations'] = {}
11
+ translation_sources.each { |key, value| site.data['translations'][key] = JSON.parse(open(value).read) }
11
12
  end
12
13
  end
13
14
 
@@ -17,7 +18,7 @@ module Jekyll
17
18
  @skipTranslationCheck = nil
18
19
  @debug_translations = false
19
20
 
20
- def translations
21
+ def translations(locale)
21
22
  return @translations if @translations
22
23
 
23
24
  site = @context.registers[:site]
@@ -25,7 +26,7 @@ module Jekyll
25
26
  @skipTranslationCheck = config['skipTranslationCheck']
26
27
  @debug_translations = !@skipTranslationCheck and ENV['DEBUG_TRANSLATIONS'].to_i === 1
27
28
 
28
- translation_data = site.data['translations']
29
+ translation_data = site.data['translations'][locale]
29
30
  translations = translation_data['common']
30
31
 
31
32
  if config['context'] and translation_data[config['context']]
@@ -46,7 +47,10 @@ module Jekyll
46
47
  # If we've an array, translate each item and return
47
48
  return self.translate_array(text) if text.kind_of?(Array)
48
49
 
49
- @translations = self.translations
50
+ page = @context.environments.first['page']
51
+ locale = page['locale'] ? page['locale'] : 'default'
52
+
53
+ @translations = self.translations(locale)
50
54
 
51
55
  # Uncomment the following block to see a list of items missing translations
52
56
  # if @translations[text].nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-translations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Dalton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -22,6 +22,7 @@ files:
22
22
  - README.md
23
23
  - bin/console
24
24
  - bin/setup
25
+ - jekyll-translations-0.1.1.gem
25
26
  - jekyll-translations.gemspec
26
27
  - lib/jekyll-translations.rb
27
28
  - lib/jekyll/translations.rb
@@ -45,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
46
  version: '0'
46
47
  requirements: []
47
48
  rubyforge_project:
48
- rubygems_version: 2.6.14
49
+ rubygems_version: 2.5.2.3
49
50
  signing_key:
50
51
  specification_version: 4
51
52
  summary: Translation tool for Jekyll