Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isSystemLanguage (language) {
const iso639 = require('iso-639-1')
const osLangISO = window.navigator.language.split('-')[0] // eg 'en'
const langIso = iso639.getCode(language) // eg 'de' if language is 'German'
return langIso === osLangISO
}
async run(message, { targetLang }) {
const langCode = ISO6391.getCode(targetLang);
if (langCode === '')
return message.channel.send('Please provide a valid language!');
// text needs to be less than 3000 length
await message.channel.send(
`Please enter the text you want to translate to ${targetLang}`
);
try {
const filter = msg => msg.content.length > 0 && msg.content.length < 3000;
var response = await message.channel.awaitMessages(filter, {
max: 1,
maxProcessed: 1,
time: 90000,
errors: ['time']
function onAddLanguage(): void {
const code = ISO6391.getCode(language);
if (!code) return;
// Add language to pub
if (!pub!.languages.includes(code)) pub!.languages.push(code);
setPub(pub);
}
answers[answer] = answers[answer].map(answer => ISO6391.getCode(answer));
}