UNPKG

xliff

Version:

xliff2js and js2xliff converter xliff utils

15 lines (13 loc) 281 B
const map = { '&': '&amp;', // this must be the first !!! '"': '&quot;', '\'': '&apos;', '<': '&lt;', '>': '&gt;' } export default function (str) { Object.keys(map).forEach(function (char) { str = str.replace(new RegExp(char, 'g'), map[char]) }) return str };