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 +4 -4
- data/README.md +25 -1
- data/jekyll-chatgpt-translate.gemspec +1 -1
- data/lib/jekyll-chatgpt-translate/generator.rb +6 -0
- data/lib/jekyll-chatgpt-translate/plain.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12d3fb457c7565b3726be719790ec577aa436e4725380aa1f7ce45b1dcc008d1
|
4
|
+
data.tar.gz: 03ce94a20742b6489b018f01bc19c309bc0eed8891a35e1c3737bf744187ed2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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.
|
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
|