jekyll-translations 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8f072fa67b86fd28d693032f390a3c9328364dbe
4
- data.tar.gz: 18490b493a89dbec2c72be8f7fdb8521826fb724
2
+ SHA256:
3
+ metadata.gz: 6d67696a7fe385237d6ea65429cc759c40caaae0fc0d04b646405593c792b5b3
4
+ data.tar.gz: 94e6b3251c933d79e524f0515fe277209ab2a5ec540148a0ef32200f659a44ab
5
5
  SHA512:
6
- metadata.gz: 4b8c37a27179ce8a0800ff46b66a9e9441fb7a1248dfa1025daa8772aa54614245720c1096f8054a13f217124bb3b3c3305c22e7b248a76a4e872c946658f5d6
7
- data.tar.gz: eaba7423c0883035b99fff0abd9a60f68b56bd6c40023f3a544b2a820d0e9aba4ca55cd668b7753b40cdd3db127008c96f12e97af08e1925fd9a217d0323b9a2
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
@@ -5,3 +5,4 @@
5
5
  /doc/
6
6
  /pkg/
7
7
  /tmp/
8
+ .gem
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))
@@ -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 = "1.0.0"
4
- spec.authors = ["Jordan Dalton"]
5
- spec.email = ["jordan.dalton@researchsquare.com"]
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"
@@ -16,6 +16,7 @@ module Jekyll
16
16
  @translations = []
17
17
  @localizationContext = nil
18
18
  @skipTranslationCheck = nil
19
+ @showTerm = false
19
20
  @debug_translations = false
20
21
 
21
22
  def translations(locale)
@@ -24,6 +25,7 @@ module Jekyll
24
25
  site = @context.registers[:site]
25
26
  config = site.config['translations']
26
27
  @skipTranslationCheck = config['skipTranslationCheck']
28
+ @showTerm = !!config['showTerms']
27
29
  @debug_translations = !@skipTranslationCheck and ENV['DEBUG_TRANSLATIONS'].to_i === 1
28
30
 
29
31
  translation_data = site.data['translations'][locale]
@@ -43,6 +45,28 @@ module Jekyll
43
45
  return translated_hash
44
46
  end
45
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
+
46
70
  def t(text, args = [])
47
71
  # If we've an array, translate each item and return
48
72
  return self.translate_array(text) if text.kind_of?(Array)
@@ -75,8 +99,15 @@ module Jekyll
75
99
  args = args.to_s
76
100
  end
77
101
 
78
- return (@translations[text] % args) if not args.empty?
79
- return @translations[text]
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')
80
111
  end
81
112
  end
82
113
  end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Translations
3
+ VERSION = "2.0.0"
4
+ end
5
+ end
@@ -1 +1,2 @@
1
1
  require 'jekyll/translations'
2
+ require 'jekyll/version'
metadata CHANGED
@@ -1,31 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-translations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jordan Dalton
7
+ - Research Square Company Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-03 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
15
- - jordan.dalton@researchsquare.com
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
24
26
  - bin/setup
25
- - jekyll-translations-0.1.1.gem
26
27
  - jekyll-translations.gemspec
27
28
  - lib/jekyll-translations.rb
28
29
  - lib/jekyll/translations.rb
30
+ - lib/jekyll/version.rb
29
31
  homepage: https://github.com/researchsquare/jekyll-translations
30
32
  licenses:
31
33
  - MIT
@@ -45,8 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
47
  - !ruby/object:Gem::Version
46
48
  version: '0'
47
49
  requirements: []
48
- rubyforge_project:
49
- rubygems_version: 2.5.2.3
50
+ rubygems_version: 3.2.3
50
51
  signing_key:
51
52
  specification_version: 4
52
53
  summary: Translation tool for Jekyll
Binary file