You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
465 B
JavaScript
23 lines
465 B
JavaScript
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
function normalizeLocaleName(locale) {
|
|
if (/^en-/.test(locale)) {
|
|
return 'en';
|
|
}
|
|
|
|
return locale;
|
|
}
|
|
|
|
function getLocaleMessages(locale) {
|
|
const onDiskLocale = locale.replace('-', '_');
|
|
const targetFile = path.join(__dirname, '_locales', onDiskLocale, 'messages.json');
|
|
|
|
return JSON.parse(fs.readFileSync(targetFile, 'utf-8'))
|
|
}
|
|
|
|
module.exports = {
|
|
normalizeLocaleName,
|
|
getLocaleMessages
|
|
}
|