Fix auto detect language for translate service (#19244)
parent
dcc0ed355e
commit
18159affbf
|
@ -20,7 +20,7 @@
|
||||||
"forwardPorts": [3000, 4000],
|
"forwardPorts": [3000, 4000],
|
||||||
|
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
"postCreateCommand": "bundle install --path vendor/bundle && yarn install && ./bin/rails db:setup",
|
"postCreateCommand": "bundle install --path vendor/bundle && yarn install && git checkout -- Gemfile.lock && ./bin/rails db:setup",
|
||||||
|
|
||||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||||
"remoteUser": "vscode"
|
"remoteUser": "vscode"
|
||||||
|
|
|
@ -27,6 +27,7 @@ services:
|
||||||
ES_ENABLED: 'true'
|
ES_ENABLED: 'true'
|
||||||
ES_HOST: es
|
ES_HOST: es
|
||||||
ES_PORT: '9200'
|
ES_PORT: '9200'
|
||||||
|
LIBRE_TRANSLATE_ENDPOINT: http://libretranslate:5000
|
||||||
# Overrides default command so things don't shut down after the process ends.
|
# Overrides default command so things don't shut down after the process ends.
|
||||||
command: sleep infinity
|
command: sleep infinity
|
||||||
networks:
|
networks:
|
||||||
|
@ -72,6 +73,12 @@ services:
|
||||||
soft: -1
|
soft: -1
|
||||||
hard: -1
|
hard: -1
|
||||||
|
|
||||||
|
libretranslate:
|
||||||
|
image: libretranslate/libretranslate:v1.2.9
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- internal_network
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres-data:
|
postgres-data:
|
||||||
redis-data:
|
redis-data:
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TranslationService::DeepL < TranslationService
|
||||||
private
|
private
|
||||||
|
|
||||||
def request(text, source_language, target_language)
|
def request(text, source_language, target_language)
|
||||||
req = Request.new(:post, endpoint_url, form: { text: text, source_lang: source_language.upcase, target_lang: target_language, tag_handling: 'html' })
|
req = Request.new(:post, endpoint_url, form: { text: text, source_lang: source_language&.upcase, target_lang: target_language, tag_handling: 'html' })
|
||||||
req.add_headers('Authorization': "DeepL-Auth-Key #{@api_key}")
|
req.add_headers('Authorization': "DeepL-Auth-Key #{@api_key}")
|
||||||
req
|
req
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,8 @@ class TranslationService::LibreTranslate < TranslationService
|
||||||
private
|
private
|
||||||
|
|
||||||
def request(text, source_language, target_language)
|
def request(text, source_language, target_language)
|
||||||
req = Request.new(:post, "#{@base_url}/translate", body: Oj.dump(q: text, source: source_language, target: target_language, format: 'html', api_key: @api_key))
|
body = Oj.dump(q: text, source: source_language.presence || 'auto', target: target_language, format: 'html', api_key: @api_key)
|
||||||
|
req = Request.new(:post, "#{@base_url}/translate", body: body)
|
||||||
req.add_headers('Content-Type': 'application/json')
|
req.add_headers('Content-Type': 'application/json')
|
||||||
req
|
req
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue