Single quotes in localized strings that are to be used as javaScript strings enclosed in single quotes are not escaped

In our case, custom messages in French (containing single quotes) were overriding the default resource messages, causing inline javascript for select2 to render broken.