Aws::Translate::Client - translate_text Returns Random Do-Not-Translate IDs or Skips Translations Depending on < and > Character Usage
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Non è stato identificato alcun file del repository né alcun test. Esegui nuovamente le due riproduzioni Ruby con aws-sdk-translate 1.79.0 e confronta la richiesta del client e la risposta di AWS Translate per stabilire se il difetto si trova nel servizio o nel client; il lavoro è completato quando la responsabilità è confermata e il comportamento degli ID DNT e del testo ignorato è risolto o documentato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Sorry if this is the wrong place to report this since this is an issue with the API and not the Ruby client, but I noticed this when testing out the do-not-translate syntax and I have examples in Ruby to illustrate the problems. There are 2 issues which are probably related.
A. Internal IDs Are Returned
# Good. Skips translating the text.
Aws::Translate::Client.new.translate_text(text: '<span translate="no">Skip me</span>', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "<span translate=\"no\">Skip me</span>"
# Good. Extra ">" on the right side doesn't cause problems.
Aws::Translate::Client.new.translate_text(text: '<span translate="no">Skip me</span>>', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "<span translate=\"no\">Skip me</span> >"
# Bad. Extra "<" on the left side returns gibberish.
Aws::Translate::Client.new.translate_text(text: '<<span translate="no">Skip me</span>', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "<DNT_GEBKJMMFHEHCKOAJBKHKJHCAkDHDNDDD"
This appears to be returning a unique random ID for some kind of "Do-Not-Translate" element because the response always starts with "DNT_" or "dnt_", followed by 32 random characters.
This isn't a huge issue because the example is contrived and the input isn't valid HTML, but there may be a problem somewhere down in the do-not-translate parsing which reveals internal values.
B. Text Between Greater Than and Less Than Characters Can Remain Untranslated
Probably as a result of how the do-not-translate parsing works, there's also a different issue where text between < and > characters sometimes isn't translated depending on other punctuation involved. I'm not sure how to avoid this because even when using < and > to escape the characters some text may remain untranslated.
# Good. Translates everything when there's a "." between the "<" and ">"
text = "If expenses < revenue then we have a profit. But if expenses > revenue then we have a loss."
Aws::Translate::Client.new.translate_text(text: text, source_language_code: 'en', target_language_code: 'fr').translated_text
=> "Si les dépenses sont inférieures aux recettes, nous avons un bénéfice. Mais si dépenses > recettes, nous avons une perte."
# Bad. Skips Translating text between "<" and ">".
text = "If expenses < revenue then we have a profit, but if expenses > revenue then we have a loss."
Aws::Translate::Client.new.translate_text(text: text, source_language_code: 'en', target_language_code: 'fr').translated_text
=> "Si les dépenses sont < revenue then we have a profit, but if expenses > des recettes, nous avons une perte."
# Bad. Skips Translating text between "<" and ">".
text = "If expenses < revenue then we have a profit, but if expenses > revenue then we have a loss."
Aws::Translate::Client.new.translate_text(text: text, source_language_code: 'en', target_language_code: 'fr').translated_text
=> "Si les dépenses sont < revenue then we have a profit, but if expenses > des recettes, nous avons une perte."
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
A. Do not return DNT ID values when there are extra < or > characters in the text.
B. Do not skip translating text between < and > characters.
Current Behavior
A. Returns "<DNT_..." value which wipes out some of the input text.
B. Skips translating text between < and > characters.
Reproduction Steps
# Returns internal DNT ID
Aws::Translate::Client.new.translate_text(text: '<<span translate="no">Skip me</span>', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "<DNT_GEBKJMMFHEHCKOAJBKHKJHCAkDHDNDDD"
# Doesn't translate text between "<" and ">" characters
text = "If expenses < revenue then we have a profit, but if expenses > revenue then we have a loss."
Aws::Translate::Client.new.translate_text(text: text, source_language_code: 'en', target_language_code: 'fr').translated_text
=> "Si les dépenses sont < revenue then we have a profit, but if expenses > des recettes, nous avons une perte."
Possible Solution
No response
Additional Information/Context
No response
Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version
aws-sdk-translate (1.79.0)
Environment details (Version of Ruby, OS environment)
Ruby 3.2.6, macOS Sonoma 14.7.3
- Lingua principale
- Ruby
- Stelle
- 3.7k
- Fork
- 1.2k
- Merge medio
- 1g 16h
- PR unite (30g)
- 25
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-sdk-ruby
-
service-api
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
aws/aws-sdk-ruby#3395 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
BedrockAgentCore: invoke_agent_runtime buffers entire response instead of streaming in real-timeApertadocumentation p3 queued
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
aws/aws-sdk-ruby#3348 · 6 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
feature-request needs-major-version
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
aws/aws-sdk-ruby#3241 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
investigating service-api
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
aws/aws-sdk-ruby#3217 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
feature-request
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws/aws-sdk-ruby#3190 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di aws/aws-sdk-ruby
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
FinanceFlash/unvibecode#273 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Widget de foto do aluno duplica os controles quando o mesmo aluno está aberto em duas ediçõesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
we-promise/sure#4481 ·
I maintainer di solito rispondono entro 1 giorno
-
data error
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
riscv/riscv-unified-db#2772 ·
I maintainer di solito rispondono entro 1 giorno