Fix quotation mark & apostrophe related i18n bug

Output HTML escaped localized text is not good, as Javascript does not handle HTML escaped strings and the escaped strings will be displayed in their raw format. So the fix in #4345 only makes the string does not break Javascript code, but cannot actually solve the problem introduced by #4282.

Thanks, please add a docstring here explaining what this is for.