Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary backslashes added before apostrophes in translation when using JSON output #67

Open
q-- opened this issue Oct 26, 2023 · 0 comments · May be fixed by #68
Open

Unnecessary backslashes added before apostrophes in translation when using JSON output #67

q-- opened this issue Oct 26, 2023 · 0 comments · May be fixed by #68

Comments

@q--
Copy link

q-- commented Oct 26, 2023

For values where the translation contains an apostrophe ('), a double escape character is added (\\); this will create a backslash in front of the apostrophe when rendered in the web page.

For example (from base locale en to target locale it, no overwrite existing translations, verbose on, json instead of PHP output):

"Export course": "Corso sull\\'esportazione",

This should be: "Export course": "Corso sull'esportazione",

The cause of this is the call to addslashes() in this line:

$translated_strings[$to_be_translated] = addslashes(Str::apiTranslateWithAttributes($to_be_translated, $target_locale, $this->base_locale));

This is unnecessary, as json_encode, which is called on line 48, already takes care of the necessary escaping.

@q-- q-- changed the title Unnecessary backslashes added to translation JSON files Unnecessary backslashes added before apostrophes in translation when using JSON output Oct 26, 2023
q-- added a commit to q--/laravel-google-translate that referenced this issue Oct 26, 2023
This is caused by an unnecessary call to addslashes()

Resolves tanmuhittin#67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant