jekyll-translations 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -14
- data/jekyll-translations-0.1.1.gem +0 -0
- data/jekyll-translations.gemspec +1 -1
- data/lib/jekyll/translations.rb +9 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f072fa67b86fd28d693032f390a3c9328364dbe
|
4
|
+
data.tar.gz: 18490b493a89dbec2c72be8f7fdb8521826fb724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b8c37a27179ce8a0800ff46b66a9e9441fb7a1248dfa1025daa8772aa54614245720c1096f8054a13f217124bb3b3c3305c22e7b248a76a4e872c946658f5d6
|
7
|
+
data.tar.gz: eaba7423c0883035b99fff0abd9a60f68b56bd6c40023f3a544b2a820d0e9aba4ca55cd668b7753b40cdd3db127008c96f12e97af08e1925fd9a217d0323b9a2
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Jekyll::Translations
|
2
2
|
|
3
|
-
|
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
|
-
|
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.
|
Binary file
|
data/jekyll-translations.gemspec
CHANGED
data/lib/jekyll/translations.rb
CHANGED
@@ -5,9 +5,10 @@ module Jekyll
|
|
5
5
|
module Translations
|
6
6
|
class Generator < Jekyll::Generator
|
7
7
|
def generate(site)
|
8
|
-
|
8
|
+
translation_sources = site.config['translations']['sources']
|
9
9
|
|
10
|
-
site.data['translations'] =
|
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
|
-
|
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:
|
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:
|
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.
|
49
|
+
rubygems_version: 2.5.2.3
|
49
50
|
signing_key:
|
50
51
|
specification_version: 4
|
51
52
|
summary: Translation tool for Jekyll
|