Skip to content

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

@q--

Description

@q--

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions