This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @webreflection's i18n.js | |
// More at https://medium.com/@WebReflection/easy-i18n-in-10-lines-of-javascript-poc-eb9e5444d71e | |
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(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 25 July 2018 | |
// forked from https://gist.github.com/sstur/7379870 | |
// modified: | |
// + reduce key assignment logic | |
// + eliminate accidental globals | |
// + use attr.name, attr.value, instead of attr[0], attr[1] | |
// + add a couple tests at the end. | |
function toJSON(node) { | |
node = node || this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 17 November 2017 | |
// original https://gist.github.com/airportyh/203f7c2d8a8b29af44218b79596af32f | |
// from @airporty https://twitter.com/airportyh/status/931540087602581504 | |
// The initial refactoring breaks `main()` steps to smaller functions, but adds | |
// whitespace. | |
// 21 November 2017 - added discrete unit tests for each function, vastly more | |
// robust, heavily renamed, heavier on comments. |