Switch out space for non-breaking space

Spaces will allow the text to wrap in non-ideal positions. Replace with a non-breaking space. Also includes the Arabic fixes.

HTML

idę sobie z
moim kumplem tak jakoś czas leci teraz szybciej może trochę i jeszcze szybciej z ambiwalentnym

JavaScript

var locale = "fr",
    formatter = new Intl.NumberFormat(locale, {
        style: "percent"
    }),
    usedLocale = formatter.resolvedOptions().locale,
    formattedNum = formatter.format(100000000000.100);

console.log("Original:" + formattedNum);

// replace regular spaces with no-break spaces
if (formattedNum.indexOf(" ") !== -1) {
    formattedNum = formattedNum.replace(/ /g, " ");
}

if ((usedLocale === "ar" || usedLocale.indexOf("ar-") === 0)) {
    if (formattedNum.indexOf(",") !== -1) {
        formattedNum = formattedNum.replace(/,/g, "٬");
    }

    // assumes only one percentage sign in the string
    if (formattedNum.indexOf("%") !== -1) {
        console.log("Hello");
        formattedNum = formattedNum.replace("%", "٪");
    }
}

console.log("Fixed: " + formattedNum);