96% of my labels were translated. The other 4% could never be.

javascript dev.to

My site ships in five languages. The calculator results go through a dictionary: function T(s) { var d = window.CH_CALC; // { "English label": "translation" } return (d && Object.prototype.hasOwnProperty.call(d, s)) ? d[s] : s; } Look up the English, fall back to the English. It is about as simple as translation gets, and for most of the site it works. Then I read a CPM calculator row on the Spanish page: Impresiones 20,000 Coste por impresión 0.0

Read Full Tutorial open_in_new
arrow_back Back to Tutorials