JSFiddle - React, Tailwind, and code Playground
by AlexMost
HTML
<script src="https://unpkg.com/c-3po@0.4.6/dist/c3po.js"></script>
<div id='content-en'></div>
<div id='content-uk'></div>
JavaScript
// more about this example - https://c-3po.js.org/translations-without-transpile.html
// data from .po file (fetched with gettext-parser lib)
const ukLocale = {
'translations': {
'': {
'Simple test': {
'msgid': 'Simple test','msgstr': ['Simple test [translated]']
}
}
}
}
addLocale('uk', ukLocale);
const contentEn = document.getElementById('content-en');
const contentUk = document.getElementById('content-uk');
useLocale('en');
contentEn.innerHTML = `<h2>${ gettext('Simple test') }</h2>`;
useLocale('uk');
contentUk.innerHTML = `<h2>${ gettext('Simple test') }</h2>`;