Give your JavaScript the ability to speak many languages.
Polyglot.js by airbnb
Is there a way to internationalize a website without adding translation wrappers within html templates?
For example, polyglot allows this syntax:
<p class="car listings'>polyglot.t("sportscars")</p>
However, it seems there should be a way to do it programmatically so that my text could acts as keys and keep the html readable. The text could work as a key in a json file the same way it does when called by the polyglot function, but just without the lengthy wrapper. I want the html itself to act as the wrapper that triggers the translation when the browser settings are set to french or another language.:
<p class="car listings'>sportscars</p>
Or if that's not possible should I create a custom wrapper, like this:
<p class="car listings'>[sportscars]</p>
that triggers the translation? Or is there a better way to programatically and a function to all html that wraps text?
Source: (StackOverflow)