How to use the iso-639-1.getCode function in iso-639-1

To help you get started, we’ve selected a few iso-639-1 examples, based on popular ways it is used in public projects.

github webtorrent / webtorrent-desktop / src / renderer / controllers / subtitles-controller.js View on Github external
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
}
github galnir / Master-Bot / commands / other / translate.js View on Github external
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']
github xyfir / illuminsight / components / Edit.tsx View on Github external
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);
  }
github Coding-Coach / find-a-mentor / scripts / create-user.js View on Github external
      answers[answer] = answers[answer].map(answer => ISO6391.getCode(answer));
    }