Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.pre = function (req, res, _type) {
i18n.configure({
directory: __dirname + '/locales',
defaultLocale: 'en-GB',
register: req
});
if (req.data.request.locale) {
i18n.setLocale(req.data.request.locale);
}
// Error if the application ID of the request is not for this skill
if (req.applicationId != applicationId &&
req.getSession().details.application.applicationId != applicationId) {
throw "Invalid applicationId";
}
// Check that the user has an access token, if they have linked their account
if (!(req.context.System.user.accessToken || req.getSession().details.user.accessToken)) {
res.say(req.__("You have not linked your Spotify account, check your Alexa app to link the account"));
res.linkAccount();
}
};
// 2. Environment variables
// 3. The file 'config.json'
nconf.argv()
.env()
.file({
file: './config.json'
});
i18n.configure({
locales: ['en', 'zh', 'de', 'es', 'fr', 'it', 'ja', 'ru'],
defaultLocale: 'en',
updateFiles: false,
extension: '.js',
directory: __dirname + '/locales'
});
i18n.setLocale(nconf.get('locale'));
var SIRI_SERVER = nconf.get('server') || 'guzzoni.apple.com',
SIRI_PORT = nconf.get('port') || 443,
DUMP_DATA = (nconf.get('dumpdata') === null) ? false : nconf.get('dumpdata'),
DNS_PROXY = (nconf.get('dnsproxy') === null) ? true : nconf.get('dnsproxy');
function __(str) {
return i18n.__(str);
}
function toArray(list) {
return [].slice.call(list, 0);
}
function fixNum(num, len) {
num |= 0;
return match;
});
// Looking for language match
if (!fullMatch) {
Object.keys(i18n.getCatalog())
.some(key => {
const match = key.toLowerCase() === appLanguage.toLowerCase();
if (match) {
resultLocale = key;
}
return match;
});
}
i18n.setLocale(resultLocale);
};
function setOrDetectLocale(locale) {
const how = locale ? 'specified' : 'detected';
let _locale = locale || osLocale.sync();
_locale = _locale.substr(0, 2);
if (_locale && !isSupported(_locale)) {
console.warn(`===== locale ${_locale} ${how} but not supported, default: en =====`.yellow);
return;
}
return i18n.setLocale(_locale);
}
export function invokeConnectionLocale(connection: Connection) {
const cmdParts = config.i18n.determineConnectionLocale.split(".");
const method: Function = dotProp.get(i18n, cmdParts.join("."));
const locale = method(connection);
I18n.setLocale(connection, locale);
}
setLocale: function (locale:string):void {
i18n.setLocale(locale);
},
Signatures.buttons = (language, buttons) => {
i18n.setLocale(language || 'en')
let secondary = ''
if (buttons.secondary) {
secondary = `
<a style="padding: 8px 12px;border-radius: 2px;font-family: Helvetica, Arial, sans-serif;font-size: 14px; color: #ffffff;text-decoration: none;font-weight:bold;display: inline-block;" href="${buttons.secondary.url}">
${i18n.__(buttons.secondary.label)}
</a>
`
}
return `
<table cellpadding="0" cellspacing="0" width="100%" style="margin-top: 20px">
<tbody><tr>
<td>
<table cellpadding="0" cellspacing="20">
<tbody><tr>
<td bgcolor="#009688" style="border-radius: 2px;"></td></tr></tbody></table></td></tr></tbody></table>
exports.sendResetPasswordEmailMessage = async (locale, user) => {
i18n.setLocale(locale)
const subject = i18n.__('forgotPassword.SUBJECT')
const htmlMessage = i18n.__(
'forgotPassword.MESSAGE',
user.email,
process.env.FRONTEND_URL,
user.verification
)
const data = {
user,
subject,
htmlMessage
}
const email = {
subject,
htmlMessage,
verification: user.verification
Sendmail.error = (user, subject, msg) => {
const to = user.email
const language = user.language || 'en'
i18n.setLocale(language)
request(
to,
subject,
[
{
type: 'text/html',
value: `${msg}
${Signatures.sign()}`
},
]
)
}
}
.then(([ assign ]) => {
const user = assign.User
const language = user.language || 'en'
i18n.setLocale(language)
SendMail.success(
assign.User,
i18n.__('mail.assign.remove.subject'),
i18n.__('mail.assign.remove.message', { message, url: `${process.env.FRONTEND_HOST}/#/task/${task.id}`, title: task.title })
)
const ownerUser = author
const ownerlanguage = ownerUser.language || 'en'
i18n.setLocale(ownerlanguage)
SendMail.success(
ownerUser,
i18n.__('mail.assign.remove.owner.subject'),
i18n.__('mail.assign.remove.owner.message', { title: task.title, user: user.name || user.username, email: user.email, message: message, url: `${process.env.FRONTEND_HOST}/#/task/${task.id}}` })
)
return task.dataValues
})