Merge remote-tracking branch 'parent/main' into upstream-20241026
This commit is contained in:
commit
0c99b8fbb0
79 changed files with 2403 additions and 2056 deletions
|
@ -8,17 +8,27 @@ class TranslationService
|
|||
class UnexpectedResponseError < Error; end
|
||||
|
||||
def self.configured
|
||||
if ENV['DEEPL_API_KEY'].present?
|
||||
TranslationService::DeepL.new(ENV.fetch('DEEPL_PLAN', 'free'), ENV['DEEPL_API_KEY'])
|
||||
elsif ENV['LIBRE_TRANSLATE_ENDPOINT'].present?
|
||||
TranslationService::LibreTranslate.new(ENV['LIBRE_TRANSLATE_ENDPOINT'], ENV['LIBRE_TRANSLATE_API_KEY'])
|
||||
if configuration.deepl[:api_key].present?
|
||||
TranslationService::DeepL.new(
|
||||
configuration.deepl[:plan],
|
||||
configuration.deepl[:api_key]
|
||||
)
|
||||
elsif configuration.libre_translate[:endpoint].present?
|
||||
TranslationService::LibreTranslate.new(
|
||||
configuration.libre_translate[:endpoint],
|
||||
configuration.libre_translate[:api_key]
|
||||
)
|
||||
else
|
||||
raise NotConfiguredError
|
||||
end
|
||||
end
|
||||
|
||||
def self.configured?
|
||||
ENV['DEEPL_API_KEY'].present? || ENV['LIBRE_TRANSLATE_ENDPOINT'].present?
|
||||
configuration.deepl[:api_key].present? || configuration.libre_translate[:endpoint].present?
|
||||
end
|
||||
|
||||
def self.configuration
|
||||
Rails.configuration.x.translation
|
||||
end
|
||||
|
||||
def languages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue