This commit is contained in:
19
application/views/components/js_lang_script.php
Normal file
19
application/views/components/js_lang_script.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<script>
|
||||
window.lang = (function () {
|
||||
const lang = <?= json_encode(html_vars('language')) ?>;
|
||||
|
||||
return (key) => {
|
||||
if (!key) {
|
||||
return lang;
|
||||
}
|
||||
|
||||
if (!lang[key]) {
|
||||
console.error(`Cannot find translation for requested key: "${key}"`);
|
||||
return key;
|
||||
}
|
||||
|
||||
return lang[key];
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user