-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
057dc09
commit e0c156d
Showing
3 changed files
with
46 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const axios = require('axios'); | ||
const conf = require('./conf'); | ||
const logger = require('./logger'); | ||
|
||
const { config } = conf; | ||
|
||
module.exports = { | ||
get: async (options) => { | ||
const { lang } = config.browser; | ||
logger.info(`Fetching ${lang} locale`); | ||
const host = options.host || config.url.host; | ||
const version = options.version || config.url.version; | ||
const client = `${host}/${config.url.basename}`; | ||
const url = `${client}/locale?locale=${lang}`; | ||
let locale; | ||
await axios.get(url).then(async response => { | ||
switch (version) { | ||
case '2.2': | ||
const { messages } = response.data; | ||
if (messages) { | ||
locale = messages; | ||
} else { | ||
logger.error(`Missing locale messages`); | ||
} | ||
break; | ||
case '2.3': | ||
const { normalizedLocale } = response.data; | ||
const json = `${client}/locales/${normalizedLocale}.json`; | ||
await axios.get(json).then(response => { | ||
locale = response.data; | ||
}).catch(error => { | ||
logger.error(error); | ||
}); | ||
break; | ||
default: | ||
logger.error(`Invalid BigBlueButton's server version: ${version}`); | ||
} | ||
}).catch(error => { | ||
logger.error(error); | ||
}); | ||
|
||
return locale; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters