Class: I18n::Tasks::Translators::WatsonxTranslator

Inherits:
BaseTranslator show all
Defined in:
lib/i18n/tasks/translators/watsonx_translator.rb

Constant Summary collapse

BATCH_SIZE =

max allowed texts per request

50
DEFAULT_SYSTEM_PROMPT =
<<~PROMPT.squish
  You are a helpful assistant that translates content from the %{from} locale
  to the %{to} locale in an i18n locale array.
  You always preserve the structure and formatting exactly as it is.

  The array has a structured format and contains multiple strings. Your task is to translate
  each of these strings and create a new array with the translated strings.

  Reminder:
  - Translate only the text, preserving the structure and formatting.
  - Do not translate any URLs.
  - Do not translate HTML tags like `<details>` and `<summary>`.
  - HTML markups (enclosed in < and > characters) must not be changed under any circumstance.
  - Variables (starting with %%{ and ending with }) must not be changed under any circumstance.
  - Output only the result, without any additional information or comments.
PROMPT

Constants included from Logging

Logging::MUTEX, Logging::PROGRAM_NAME

Instance Method Summary collapse

Methods inherited from BaseTranslator

#initialize, #translate_forest

Methods included from Logging

log_error, log_stderr, log_verbose, log_warn, program_name, warn_deprecated

Constructor Details

This class inherits a constructor from I18n::Tasks::Translators::BaseTranslator

Instance Method Details

#no_results_error_messageObject



42
43
44
# File 'lib/i18n/tasks/translators/watsonx_translator.rb', line 42

def no_results_error_message
  I18n.t('i18n_tasks.watsonx_translate.errors.no_results')
end

#options_for_htmlObject



34
35
36
# File 'lib/i18n/tasks/translators/watsonx_translator.rb', line 34

def options_for_html
  {}
end

#options_for_plainObject



38
39
40
# File 'lib/i18n/tasks/translators/watsonx_translator.rb', line 38

def options_for_plain
  {}
end

#options_for_translate_values(from:, to:, **options) ⇒ Object



27
28
29
30
31
32
# File 'lib/i18n/tasks/translators/watsonx_translator.rb', line 27

def options_for_translate_values(from:, to:, **options)
  options.merge(
    from: from,
    to: to
  )
end