Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
koa-i18next-detector
Advanced tools
A i18next language detecting plugin for Koa 2.0 framework.
npm i -S koa-i18next-detector
const i18next = require('i18next');
import koaI18nextDetector from 'koa-i18next-detector';
// add custom detector.
const lngDetector = new koaI18nextDetector();
lngDetector.addDetector({
name: 'mySessionDetector',
lookup(ctx, options) {
let found;
if (options.lookupSession && ctx && ctx.sessions) {
found = ctx.sessions[options.lookupMySession];
}
return found;
},
cacheUserLanguage(ctx, lng, options = {}) {
if (options.lookupMySession && ctx && ctx.session) {
ctx.session[options.lookupMySession] = lng;
}
}
});
i18next.use(lngDetector).init(
{
fallbackLng: 'en',
preload: ['en', 'es'],
resources: {
en: {
translation: {
key: 'hello world'
}
},
es: {
translation: {
key: 'es hello world es'
}
}
},
detection: {
order: [
'querystring',
'path',
/*'cookie', 'header',*/ 'session',
'mySessionDetector'
],
lookupQuerystring: 'lng',
lookupParam: 'lng', // for route like: 'path1/:lng/result'
lookupFromPathIndex: 0,
// currently using ctx.cookies
lookupCookie: 'i18next',
// cookieExpirationDate: new Date(), // default: +1 year
// cookieDomain: '', // default: current domain.
// currently using ctx.session
lookupSession: 'lng',
// other options
lookupMySession: 'lang',
// cache user language
caches: ['cookie', 'mySessionDetector']
}
},
(err, t) => {
// initialized and ready to go!
const hw = i18next.t('key'); // hw = 'hello world'
console.log(hw);
}
);
MIT © lxzxl
FAQs
A i18next language detecting plugin for Koa 2.0 framework.
The npm package koa-i18next-detector receives a total of 2,232 weekly downloads. As such, koa-i18next-detector popularity was classified as popular.
We found that koa-i18next-detector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.