jekyll-chatgpt-translate 0.0.2 → 0.0.3

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: 12d3fb457c7565b3726be719790ec577aa436e4725380aa1f7ce45b1dcc008d1
4
+ data.tar.gz: 03ce94a20742b6489b018f01bc19c309bc0eed8891a35e1c3737bf744187ed2f
5
5
  SHA512:
6
- metadata.gz: 65f1e5fc709dbf5750435dc205b70c5d1b30c51e44e6ae53b4d9c1d2d670f64b38546e033e3f9f87cd7f374d4d244f8b6f3226e4be4622a47832c84ed86f719f
7
- data.tar.gz: 1484f30b17ef150720e7cb68ac5ce136e56135e1f16706a43b7a38735922b7fdde639f5acb154edf68c66dc78ae92183232e5f1ee82dc67c946cd263c8b50afb
6
+ metadata.gz: 175718e03a2a9993edb00583b676132705a9af77ce16d0a460f28dcdc9a5bf2dfedf52d370519907e086997022a130589c0e95c74058911107fba8fb05f79fcb
7
+ data.tar.gz: 1d853b8ca20c5107dcceda0c2cb37e2eb83d50a968ebe902a0c9ba58862e68ef8fdc91ac887a666a6f155f819fa56cc2014a85b60bf48108e0b5062cccd98486
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.3'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Translate Jekyll Pages Through ChatGPT'
34
34
  s.description = [
@@ -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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko