Skip to content

Instantly share code, notes, and snippets.

@Robitx
Forked from WebReflection/i18n.js
Created August 8, 2021 19:55
Show Gist options
  • Save Robitx/bb15e78215f7e4eacbf199f273d73bd3 to your computer and use it in GitHub Desktop.
Save Robitx/bb15e78215f7e4eacbf199f273d73bd3 to your computer and use it in GitHub Desktop.
i18n in 10 lines of code
function i18n(template) {
for (var
info = i18n.db[i18n.locale][template.join('\x01')],
out = [info.t[0]],
i = 1, length = info.t.length; i < length; i++
) out[i] = arguments[1 + info.v[i - 1]] + info.t[i];
return out.join('');
}
i18n.locale = 'en';
i18n.db = {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment