
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
A modern, lightweight, and framework-agnostic internationalization library with TypeScript support.
npm install @oxog/i18n
# or
pnpm add @oxog/i18n
# or
yarn add @oxog/i18n
import { createI18n } from '@oxog/i18n';
// Create i18n instance
const i18n = createI18n({
locale: 'en',
fallbackLocale: 'en',
messages: {
en: {
greeting: 'Hello, {name}!',
messages: {
welcome: 'Welcome to our app'
}
},
es: {
greeting: '¡Hola, {name}!',
messages: {
welcome: 'Bienvenido a nuestra aplicación'
}
}
}
});
// Use translations
console.log(i18n.t('greeting', { name: 'World' })); // Hello, World!
console.log(i18n.t('messages.welcome')); // Welcome to our app
// Change locale
i18n.setLocale('es');
console.log(i18n.t('greeting', { name: 'Mundo' })); // ¡Hola, Mundo!
createI18n(options)
Creates a new i18n instance.
locale
: Current locale (default: 'en')fallbackLocale
: Fallback locale when translation is missingmessages
: Translation messages objectplugins
: Array of plugins to useinterpolation
: Custom interpolation optionsmissing
: Custom missing translation handlert(key, params?, options?)
Get a translation for the given key.
i18n.t('greeting', { name: 'Alice' });
i18n.t('user.profile.title');
setLocale(locale)
Change the current locale.
i18n.setLocale('fr');
getLocale()
Get the current locale.
const currentLocale = i18n.getLocale(); // 'en'
hasTranslation(key, locale?)
Check if a translation exists.
if (i18n.hasTranslation('feature.title')) {
// Translation exists
}
addMessages(locale, messages)
Add translations for a locale.
i18n.addMessages('de', {
greeting: 'Hallo, {name}!'
});
// Basic interpolation
i18n.t('greeting', { name: 'World' }); // Hello, World!
// Custom interpolation pattern
const i18n = createI18n({
interpolation: {
prefix: '{{',
suffix: '}}'
}
});
const messages = {
items: {
zero: 'No items',
one: 'One item',
other: '{count} items'
}
};
i18n.t('items', { count: 0 }); // No items
i18n.t('items', { count: 1 }); // One item
i18n.t('items', { count: 5 }); // 5 items
import { createI18n, ICUPlugin } from '@oxog/i18n';
const i18n = createI18n({
plugins: [ICUPlugin()],
messages: {
en: {
greeting: 'Hello, {name}! You have {count, plural, =0 {no messages} =1 {one message} other {# messages}}.'
}
}
});
const i18n = createI18n({
missing: (key, locale) => {
console.warn(`Missing translation: ${key} for locale: ${locale}`);
return key; // Return the key as fallback
}
});
// Define your message schema
type MessageSchema = {
greeting: string;
user: {
profile: {
title: string;
description: string;
};
};
};
// Create typed i18n instance
const i18n = createI18n<MessageSchema>({
locale: 'en',
messages: {
en: {
greeting: 'Hello!',
user: {
profile: {
title: 'Profile',
description: 'User profile page'
}
}
}
}
});
// Now you get full type safety
i18n.t('greeting'); // ✅ Valid
i18n.t('user.profile.title'); // ✅ Valid
i18n.t('invalid.key'); // ❌ TypeScript error
The library is optimized for performance with:
MIT © Ersin Koç
Contributions are welcome! Please read our Contributing Guide for details.
FAQs
Modern, lightweight, and framework-agnostic internationalization library
We found that @oxog/i18n demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.