jekyll-chatgpt-translate 0.0.2 → 0.0.4

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
  SHA256:
3
- metadata.gz: d4406bec62ad6c32b1dcff60e2b87e49b7aa886d483efd11d141aa55a5dcea4f
4
- data.tar.gz: d12af607c08b438cbb14d660a6347070b4c4b5bced4fbda805709b27544f20de
3
+ metadata.gz: a4a911c9ca494d5175e1e16240912894aa7fb42225a6fc02ff1a4550fbc2cfcd
4
+ data.tar.gz: 4ed03539027a1aa9d21d6def567ad60daf6e495edd4b85ec1903f866dde0262a
5
5
  SHA512:
6
- metadata.gz: 65f1e5fc709dbf5750435dc205b70c5d1b30c51e44e6ae53b4d9c1d2d670f64b38546e033e3f9f87cd7f374d4d244f8b6f3226e4be4622a47832c84ed86f719f
7
- data.tar.gz: 1484f30b17ef150720e7cb68ac5ce136e56135e1f16706a43b7a38735922b7fdde639f5acb154edf68c66dc78ae92183232e5f1ee82dc67c946cd263c8b50afb
6
+ metadata.gz: d86c34428bc11ccbbc95fd6deebbdcc14f03d195f1883abfcdf8c699d79cec0a12f089adbb38685dcc25c272480a3a3752d620275501bb41ef89c0973dbb4a4a
7
+ data.tar.gz: d3d32a7fb2c971e3a8750ab23d0359988b99bcefcfe74763d35251feb748446d004ef0ab953a8957be80bef9b60d84f497cb2a4d2f1ca8e49440def149cd31b8
data/Gemfile CHANGED
@@ -26,7 +26,6 @@ source 'https://rubygems.org'
26
26
  gemspec
27
27
 
28
28
  gem 'cucumber', '8.0.0', require: false
29
- gem 'jekyll', '3.9.3', require: false
30
29
  gem 'kramdown-parser-gfm', '1.1.0', require: false
31
30
  gem 'minitest', '5.19.0', require: false
32
31
  gem 'rake', '13.0.6', require: false
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  [![rake](https://github.com/yegor256/jekyll-chatgpt-translate/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/jekyll-chatgpt-translate/actions/workflows/rake.yml)
2
2
  [![Gem Version](https://badge.fury.io/rb/jekyll-chatgpt-translate.svg)](http://badge.fury.io/rb/jekyll-chatgpt-translate)
3
3
 
4
+ If you have a [Jekyll](https://jekyllrb.com/) static site, this plugin may help you automatically
5
+ translate its pages to another language, through [ChatGPT](https://chat.openai.com/).
6
+
4
7
  Install it first:
5
8
 
6
9
  ```
@@ -35,7 +38,28 @@ The plugin is compatible with
35
38
  [Jekyll 3.9.3](https://jekyllrb.com/news/2023/01/29/jekyll-3-9-3-released/) and
36
39
  [Jekyll 4.3.2](https://jekyllrb.com/news/2023/01/20/jekyll-4-3-2-released/).
37
40
 
38
- # How to Contribute
41
+ ## Options
42
+
43
+ Full list of options available to specify in `_config.yml`:
44
+
45
+ * `model` (optional) --- specifies the model to use by ChatGPT.
46
+
47
+ * `source` (optional) --- is the ISO-839-1 code of the source language.
48
+
49
+ * `layout` (optional) --- is name of the file in `_layouts` directory, without the extension.
50
+ This layout will be specified for the pages generated by this plugin.
51
+
52
+ * `targets` (mandatory) --- an array of target languages, each of which has the following attributes
53
+
54
+ * `language` (mandatory) --- ISO-839-1 code of the target language
55
+
56
+ * `permalink` (mandatory) --- template to use for newly generated pages
57
+
58
+ * `layout` (optional) --- the name of the file in the `_layouts` directory
59
+
60
+ * `threshold` (optional) --- maximum number of pages to generate in one build cycle.
61
+
62
+ ## How to Contribute
39
63
 
40
64
  Test is like this:
41
65
 
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
29
29
  s.required_ruby_version = '>= 2.6'
30
30
  s.name = 'jekyll-chatgpt-translate'
31
- s.version = '0.0.2'
31
+ s.version = '0.0.4'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -42,11 +42,11 @@ Gem::Specification.new do |s|
42
42
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
43
43
  s.rdoc_options = ['--charset=UTF-8']
44
44
  s.extra_rdoc_files = %w[README.md LICENSE.txt]
45
- s.add_runtime_dependency 'iri', '~> 0.6'
46
- s.add_runtime_dependency 'iso-639', '~> 0.3'
47
- s.add_runtime_dependency 'jekyll', '~> 3.9'
48
- s.add_runtime_dependency 'liquid', '~> 4.0'
49
- s.add_runtime_dependency 'redcarpet', '~> 3.6'
50
- s.add_runtime_dependency 'ruby-openai', '~> 5.0'
45
+ s.add_runtime_dependency 'iri', '~> 0'
46
+ s.add_runtime_dependency 'iso-639', '~> 0'
47
+ s.add_runtime_dependency 'jekyll', '~> 3'
48
+ s.add_runtime_dependency 'liquid', '~> 4'
49
+ s.add_runtime_dependency 'redcarpet', '~> 3'
50
+ s.add_runtime_dependency 'ruby-openai', '~> 5'
51
51
  s.metadata['rubygems_mfa_required'] = 'true'
52
52
  end
@@ -54,6 +54,7 @@ but pages will be generated')
54
54
  return
55
55
  end
56
56
  layout = config['layout'] || 'translated'
57
+ threshold = config['threshold'] || 1_000_000_000
57
58
  start = Time.now
58
59
  total = 0
59
60
  site.posts.docs.each do |doc|
@@ -64,6 +65,10 @@ but pages will be generated')
64
65
  lang = target['language']
65
66
  raise 'Language must be defined for each target' if target.nil?
66
67
  model = config['model'] || 'gpt-3.5-turbo'
68
+ if total >= threshold
69
+ Jekyll.logger.info("Already generated #{total} pages, that's enough for today")
70
+ break
71
+ end
67
72
  gpt = GptTranslate::ChatGPT.new(
68
73
  key,
69
74
  model,
@@ -90,6 +95,7 @@ but pages will be generated')
90
95
  site.pages << Jekyll::Page.new(site, site.source, File.dirname(path), File.basename(path))
91
96
  total += 1
92
97
  end
98
+ break if total >= threshold
93
99
  end
94
100
  Jekyll.logger.info("#{total} pages generated in #{(Time.now - start).round(2)}s")
95
101
  end
@@ -66,7 +66,7 @@ class GptTranslate::Plain
66
66
  block_code block_quote
67
67
  block_html
68
68
  autolink codespan double_emphasis
69
- emphasis underline raw_html
69
+ emphasis underline
70
70
  triple_emphasis strikethrough
71
71
  superscript highlight quote
72
72
  footnotes footnote_def footnote_ref
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-chatgpt-translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: iso-639
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jekyll
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.9'
47
+ version: '3'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.9'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: liquid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.6'
75
+ version: '3'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.6'
82
+ version: '3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ruby-openai
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '5.0'
89
+ version: '5'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '5.0'
96
+ version: '5'
97
97
  description: Add this plugin to your Jekyll site and all posts will be automatically
98
98
  translated to the languages of your choice through ChatGPT
99
99
  email: yegor256@gmail.com