aws / aws/aws-sdk-ruby

Aws::Translate::Client - translate_text Returns Random Do-Not-Translate IDs or Skips Translations Depending on < and > Character Usage

Open
#3,191 1 comment 0 reactions 0 assignees View on GitHub
service-api
Dominant language
Ruby
Stars
3.7k
Forks
1.2k
Avg merge
1d 4h
Merged PRs (30d)
5

Description

### 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](https://docs.aws.amazon.com/translate/latest/dg/customizing-translations-tags.html) and I have examples in Ruby to illustrate the problems. There are 2 issues which are probably related.

### A. Internal IDs Are Returned

```ruby
# Good. Skips translating the text.
Aws::Translate::Client.new.translate_text(text: 'Skip me', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "Skip me"

# Good. Extra ">" on the right side doesn't cause problems.
Aws::Translate::Client.new.translate_text(text: 'Skip me>', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "Skip me >"

# Bad. Extra "<" on the left side returns gibberish.
Aws::Translate::Client.new.translate_text(text: '<Skip me', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "` 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.

```ruby
# 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 `"Skip me', source_language_code: 'en', target_language_code: 'fr').translated_text
=> "" 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.