forgot to build

This commit is contained in:
2022-02-13 21:42:04 -06:00
parent f5ab2b4297
commit 8503f274bd
7 changed files with 248 additions and 245 deletions

79
dist/lang.js vendored
View File

@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lang = void 0;
exports.get = exports.setLang = void 0;
const LANG = {
en: {
main: {
@@ -20,7 +20,7 @@ const LANG = {
discord: {
noQueue: 'There is not an active queue in this channel, type `/open` to create one',
noChannel: 'Unable to find channel {channelId} for teams of {teamsize}',
noCreate: 'There is already an active queue in this channel for teams of ${teamsize}',
noCreate: 'There is already an active queue in this channel for teams of {teamsize}',
inQueue: 'You are already in the queue',
notInQueue: 'You aren\'t in the queue',
notMod: 'Member is not a moderator'
@@ -35,45 +35,42 @@ const LANG = {
}
}
};
var Lang;
(function (Lang) {
var LANGID = 'en';
if (!(LANGID in LANG))
let LANGID = 'en';
if (!(LANGID in LANG))
throw 'language id does not exist';
function setLang(langid) {
if (langid in LANG)
LANGID = langid;
else
throw 'language id does not exist';
function setLang(langid) {
if (langid in LANG)
LANGID = langid;
else
throw 'language id does not exist';
}
Lang.setLang = setLang;
function template(str, args) {
return str.replace(/{\w+}/g, str => {
let key = str.substring(1, str.length - 1);
if (key in args)
return args[key];
return key;
});
}
/**
* reads language json
* @param id ex: discord.error.noActiveQueue
* @returns language value, defaults to `id` parameter
*/
function get(id, args = {}) {
let keySpl = id.split('.').map(k => k.trim()).filter(k => k);
let finding = LANG[LANGID];
for (let key of keySpl) {
if (key in finding) {
let found = finding[key];
if (typeof found === 'string')
return template(found, args);
finding = found;
}
else
break;
}
exports.setLang = setLang;
function template(str, args) {
return str.replace(/{\w+}/g, str => {
const key = str.substring(1, str.length - 1);
if (key in args)
return args[key];
return key;
});
}
/**
* reads language json
* @param id ex: discord.error.noActiveQueue
* @returns language value, defaults to `id` parameter
*/
function get(id, args = {}) {
const keySpl = id.split('.').map(k => k.trim()).filter(k => k);
let finding = LANG[LANGID];
for (const key of keySpl) {
if (key in finding) {
const found = finding[key];
if (typeof found === 'string')
return template(found, args);
finding = found;
}
return id;
else
break;
}
Lang.get = get;
})(Lang = exports.Lang || (exports.Lang = {}));
return id;
}
exports.get = get;