lib/jekyll-chatgpt-translate/prompt.rb in jekyll-chatgpt-translate-0.0.35 vs lib/jekyll-chatgpt-translate/prompt.rb in jekyll-chatgpt-translate-0.0.36
- old
+ new
@@ -21,10 +21,11 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'iso-639'
+require 'humanize'
# The module we are in.
module GptTranslate; end
# Prompt for ChatGPT.
@@ -45,11 +46,14 @@
def to_s
from = ISO_639.find_by_code(@source)
raise "Unknown source language ISO-639 code: #{@source.inspect}" if from.nil?
to = ISO_639.find_by_code(@target)
raise "Unknown source language ISO-639 code: #{@target.inspect}" if to.nil?
+ md = @par
+ parts = md.split("\n\n")
+ label = parts.size > 1 ? "#{parts.size.humanize(locale: :en)} Markdown paragraphs" : 'Markdown paragraph'
head = [
- 'Please, translate the following Markdown paragraph from ',
+ "Please, translate the following #{label} from ",
from[3],
' to ',
to[3],
', don\'t translate technical terms and proper nouns'
].join