How to use @cospired/i18n-iso-languages - 2 common examples

To help you get started, we’ve selected a few @cospired/i18n-iso-languages examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cboard-org / cboard / src / i18n.js View on Github external
export function standardizeLanguageCode(lang) {
  const splittedLang = lang.split(splitLangRgx);
  if (splittedLang.length < 1) {
    return lang;
  }
  let standardLang =
    splittedLang[0].length === 3
      ? alpha3TToAlpha2(splittedLang[0])
      : splittedLang[0];

  if (splittedLang.length === 1) {
    return standardLang;
  }

  let standardCountry =
    splittedLang[1].length === 3
      ? alpha3ToAlpha2(splittedLang[1])
      : splittedLang[1];

  return `${standardLang}-${standardCountry}`;
}
github cboard-org / cboard / src / api / api.js View on Github external
async globalsymbolsPictogramsSearch(locale, searchText) {
    let language = 'eng';
    if (locale.length === 3) {
      language = locale;
    }
    if (locale.length === 2) {
      language = alpha2ToAlpha3T(locale);
    }
    const pictogSearchTextPath = `${GLOBALSYMBOLS_BASE_PATH_API}labels/search/?query=${searchText}&language=${language}&language_iso_format=639-3&limit=20`;
    try {
      const { status, data } = await this.axiosInstance.get(
        pictogSearchTextPath
      );
      if (status === 200) return data;
      return [];
    } catch (err) {
      return [];
    }
  }

@cospired/i18n-iso-languages

i18n for ISO 639 language codes

MIT
Latest version published 10 months ago

Package Health Score

70 / 100
Full package analysis