jekyll-translations 0.1.0 → 2.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 +5 -5
- data/.github/workflows/release.yml +55 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +13 -0
- data/README.md +2 -14
- data/jekyll-translations.gemspec +7 -3
- data/lib/jekyll/translations.rb +42 -7
- data/lib/jekyll/version.rb +5 -0
- data/lib/jekyll-translations.rb +1 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6d67696a7fe385237d6ea65429cc759c40caaae0fc0d04b646405593c792b5b3
|
4
|
+
data.tar.gz: 94e6b3251c933d79e524f0515fe277209ab2a5ec540148a0ef32200f659a44ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb51ce3fe0b04c37d5b0a32f8bfb836a93abccf53f978935c976da715c6d08b5f4c68aad9b388c2fe6befcb21ecaccddeab79b1753d2ee5207c51b86f6310243
|
7
|
+
data.tar.gz: 94404d93696ef1ea6c4b9d54a63f651730a86b6e80f1af1381765ea203320a3d9e6c29c484dee8430f025bedea837041504503ae97bab981acab722f86114cb6
|
@@ -0,0 +1,55 @@
|
|
1
|
+
name: release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: write
|
10
|
+
pull-requests: write
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
release-please:
|
14
|
+
runs-on: [ubuntu-latest]
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- name: Release Please
|
18
|
+
uses: GoogleCloudPlatform/release-please-action@v3
|
19
|
+
id: release
|
20
|
+
with:
|
21
|
+
release-type: ruby
|
22
|
+
package-name: jekyll-translations
|
23
|
+
bump-minor-pre-major: true
|
24
|
+
version-file: "lib/jekyll/version.rb"
|
25
|
+
|
26
|
+
outputs:
|
27
|
+
release_created: ${{ steps.release.outputs.release_created }}
|
28
|
+
|
29
|
+
publish-gem:
|
30
|
+
runs-on: [ubuntu-latest]
|
31
|
+
needs: [release-please]
|
32
|
+
if: ${{ needs.release-please.outputs.release_created }}
|
33
|
+
|
34
|
+
steps:
|
35
|
+
- name: Checkout
|
36
|
+
uses: actions/checkout@v3
|
37
|
+
|
38
|
+
- name: Setup Ruby
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: 3.0.0
|
42
|
+
|
43
|
+
- name: Install the bundle
|
44
|
+
run: bundle install
|
45
|
+
|
46
|
+
- name: publish gem
|
47
|
+
env:
|
48
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
49
|
+
run: |
|
50
|
+
mkdir -p $HOME/.gem
|
51
|
+
touch $HOME/.gem/credentials
|
52
|
+
chmod 0600 $HOME/.gem/credentials
|
53
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
54
|
+
gem build *.gemspec
|
55
|
+
gem push *.gem
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [2.0.0](https://github.com/researchsquare/jekyll-translations/compare/v1.0.0...v2.0.0) (2023-09-25)
|
4
|
+
|
5
|
+
|
6
|
+
### ⚠ BREAKING CHANGES
|
7
|
+
|
8
|
+
* Force 2.0.0 version
|
9
|
+
|
10
|
+
### Features
|
11
|
+
|
12
|
+
* Add optional wrapping of translation with html tag ([4ed6c89](https://github.com/researchsquare/jekyll-translations/commit/4ed6c899207701d6d0bf3b76a361eaaec53deb11))
|
13
|
+
* Force 2.0.0 version ([2f37b24](https://github.com/researchsquare/jekyll-translations/commit/2f37b24974f5e34bee4c5357654992d27d80f540))
|
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.
|
data/jekyll-translations.gemspec
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'jekyll/version'
|
4
|
+
|
1
5
|
Gem::Specification.new do |spec|
|
2
6
|
spec.name = "jekyll-translations"
|
3
|
-
spec.version =
|
4
|
-
spec.authors = ["
|
5
|
-
spec.email = ["
|
7
|
+
spec.version = Jekyll::Translations::VERSION
|
8
|
+
spec.authors = ["Research Square Company Engineering"]
|
9
|
+
spec.email = ["customer@researchsquare.com"]
|
6
10
|
spec.require_paths = ["lib"]
|
7
11
|
spec.summary = %q{Translation tool for Jekyll}
|
8
12
|
spec.homepage = "https://github.com/researchsquare/jekyll-translations"
|
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
|
|
@@ -15,17 +16,19 @@ module Jekyll
|
|
15
16
|
@translations = []
|
16
17
|
@localizationContext = nil
|
17
18
|
@skipTranslationCheck = nil
|
19
|
+
@showTerm = false
|
18
20
|
@debug_translations = false
|
19
21
|
|
20
|
-
def translations
|
22
|
+
def translations(locale)
|
21
23
|
return @translations if @translations
|
22
24
|
|
23
25
|
site = @context.registers[:site]
|
24
26
|
config = site.config['translations']
|
25
27
|
@skipTranslationCheck = config['skipTranslationCheck']
|
28
|
+
@showTerm = !!config['showTerms']
|
26
29
|
@debug_translations = !@skipTranslationCheck and ENV['DEBUG_TRANSLATIONS'].to_i === 1
|
27
30
|
|
28
|
-
translation_data = site.data['translations']
|
31
|
+
translation_data = site.data['translations'][locale]
|
29
32
|
translations = translation_data['common']
|
30
33
|
|
31
34
|
if config['context'] and translation_data[config['context']]
|
@@ -42,11 +45,36 @@ module Jekyll
|
|
42
45
|
return translated_hash
|
43
46
|
end
|
44
47
|
|
48
|
+
def show_translation_term(translation, tag)
|
49
|
+
if @showTerm && !@showTermOverride
|
50
|
+
return "<#{tag} title=\"#{@lastTerm}\">#{translation}</#{tag}>"
|
51
|
+
end
|
52
|
+
|
53
|
+
return translation
|
54
|
+
end
|
55
|
+
|
56
|
+
def tns(text, args = [])
|
57
|
+
@showTermOverride = true;
|
58
|
+
|
59
|
+
translated = self.t(text, args)
|
60
|
+
|
61
|
+
@showTermOverride = false;
|
62
|
+
|
63
|
+
return translated
|
64
|
+
end
|
65
|
+
|
66
|
+
def ts(translation)
|
67
|
+
return self.show_translation_term(translation, 'div')
|
68
|
+
end
|
69
|
+
|
45
70
|
def t(text, args = [])
|
46
71
|
# If we've an array, translate each item and return
|
47
72
|
return self.translate_array(text) if text.kind_of?(Array)
|
48
73
|
|
49
|
-
|
74
|
+
page = @context.environments.first['page']
|
75
|
+
locale = page['locale'] ? page['locale'] : 'default'
|
76
|
+
|
77
|
+
@translations = self.translations(locale)
|
50
78
|
|
51
79
|
# Uncomment the following block to see a list of items missing translations
|
52
80
|
# if @translations[text].nil?
|
@@ -71,8 +99,15 @@ module Jekyll
|
|
71
99
|
args = args.to_s
|
72
100
|
end
|
73
101
|
|
74
|
-
|
75
|
-
|
102
|
+
if not args.empty?
|
103
|
+
translated = (@translations[text] % args)
|
104
|
+
else
|
105
|
+
translated = @translations[text]
|
106
|
+
end
|
107
|
+
|
108
|
+
@lastTerm = text
|
109
|
+
|
110
|
+
return self.show_translation_term(translated, 'span')
|
76
111
|
end
|
77
112
|
end
|
78
113
|
end
|
data/lib/jekyll-translations.rb
CHANGED
metadata
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-translations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Research Square Company Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
15
|
-
-
|
15
|
+
- customer@researchsquare.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/workflows/release.yml"
|
20
21
|
- ".gitignore"
|
22
|
+
- CHANGELOG.md
|
21
23
|
- Gemfile
|
22
24
|
- README.md
|
23
25
|
- bin/console
|
@@ -25,6 +27,7 @@ files:
|
|
25
27
|
- jekyll-translations.gemspec
|
26
28
|
- lib/jekyll-translations.rb
|
27
29
|
- lib/jekyll/translations.rb
|
30
|
+
- lib/jekyll/version.rb
|
28
31
|
homepage: https://github.com/researchsquare/jekyll-translations
|
29
32
|
licenses:
|
30
33
|
- MIT
|
@@ -44,8 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
47
|
- !ruby/object:Gem::Version
|
45
48
|
version: '0'
|
46
49
|
requirements: []
|
47
|
-
|
48
|
-
rubygems_version: 2.6.14
|
50
|
+
rubygems_version: 3.2.3
|
49
51
|
signing_key:
|
50
52
|
specification_version: 4
|
51
53
|
summary: Translation tool for Jekyll
|