You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.0KB

123456789101112131415161718192021222324252627282930
  1. // @flow
  2. import i18next from 'i18next';
  3. import JITSI_TO_BCP47_MAP from './jitsiToBCP47LocaleMap.json';
  4. const DEFAULT_TRANSCRIBER_LANG = 'en-US';
  5. /**
  6. * Determine which language to use for transcribing.
  7. *
  8. * @param {*} config - Application config.
  9. * @returns {string}
  10. */
  11. export function determineTranscriptionLanguage(config: Object) {
  12. const { preferredTranscribeLanguage, transcribeWithAppLanguage = true } = config;
  13. // Depending on the config either use the language that the app automatically detected or the hardcoded
  14. // config value.
  15. const jitsiLocale = transcribeWithAppLanguage ? i18next.language : preferredTranscribeLanguage;
  16. // Jitsi uses custom language tags, but the transcriber expects BCP-47 compliant tags. We use a mapping file
  17. // to convert them.
  18. // Not all languages that the app might detect are supported by the transcriber in which case use the default.
  19. const { [jitsiLocale]: bcp47Locale = DEFAULT_TRANSCRIBER_LANG } = JITSI_TO_BCP47_MAP;
  20. return bcp47Locale;
  21. }