created lang file
This commit is contained in:
47
dist/lang.js
vendored
Normal file
47
dist/lang.js
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Lang = void 0;
|
||||
const LANG = {
|
||||
en: {
|
||||
discord: {
|
||||
error: {
|
||||
noActiveQueue: 'There is not an active queue in this channel, type `/open` to create one'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var Lang;
|
||||
(function (Lang) {
|
||||
var 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';
|
||||
}
|
||||
Lang.setLang = setLang;
|
||||
/**
|
||||
* reads language json
|
||||
* @param id ex: discord.error.noActiveQueue
|
||||
* @returns language value, defaults to `id` parameter
|
||||
*/
|
||||
function get(id) {
|
||||
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 found;
|
||||
finding = found;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
Lang.get = get;
|
||||
})(Lang = exports.Lang || (exports.Lang = {}));
|
||||
debugger;
|
||||
Reference in New Issue
Block a user