
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Type-safe internationalization tool for Next.js App Router with co-location and IDE code jumping
π Type-safe internationalization tool for Next.js App Router with co-location and IDE code jumping
npm install i18n-at
// messages.ts
import { defineMessages, at } from "i18n-at";
export const { messages } = defineMessages({
en: {
dashboard: {
title: "Dashboard",
welcome: "Welcome, {name}!",
},
},
ja: {
dashboard: {
title: "γγγ·γ₯γγΌγ",
welcome: "{name} γγγγγγγοΌ",
},
},
zh: {
dashboard: {
title: "δ»ͺ葨ζΏ",
welcome: "ζ¬’θΏοΌ{name}οΌ",
},
},
});
export type AppLocale = ExtractConfigLocales<typeof i18nConfig>;
// app/[locale]/page.tsx
import { getI18n } from "i18n-at";
import { messages } from "./messages";
export default function Page({
params: { locale },
}: {
params: { locale: string };
}) {
const { t, m } = getI18n(messages, locale); // Type-safe & IDE jumping!
return (
<div>
<h1>{t(m.dashboard.title)}</h1>
<p>{t(m.dashboard.welcome, { name: "User" })}</p>
</div>
);
}
// components/Dashboard.tsx
"use client";
import { useI18n, useLocale } from "i18n-at";
import { messages } from "./messages";
export default function Dashboard() {
const locale = useLocale();
const { t, m } = useI18n(messages); // IDE jumping works!
return (
<div>
<h1>{t(m.dashboard.title)}</h1>
<p>{t(m.dashboard.welcome, { name: "User" })}</p>
</div>
);
}
// app/layout.tsx
import { I18nClientProvider } from "@i18n-at";
export default function RootLayout({
children,
params: { locale },
}: {
children: React.ReactNode;
params: { locale: string };
}) {
return (
<html lang={locale}>
<body>
<I18nClientProvider locale={locale}>{children}</I18nClientProvider>
</body>
</html>
);
}
defineMessages(messages)
Define internationalized messages with type safety.
const { messages } = defineMessages({
en: { hello: "Hello" },
ja: { hello: "γγγ«γ‘γ―" },
});
at(locale, messages)
Get type-safe locale-specific messages.
const enMessages = at("en", messages); // Type: { hello: string }
const jaMessages = at("ja", messages); // Type: { hello: string }
getI18n(messages, locale)
Server-side translation function that returns both translator and messages.
const { t, m } = getI18n(messages, "en");
const text = t(m.hello); // "Hello" with type safety
useI18n(messages)
Client-side translation hook that returns both translator and messages.
const { t, m } = useI18n(messages);
const text = t(m.hello); // Translated text with type safety
Unlike traditional i18n solutions that force you to manage translations in separate files, i18n-at lets you define and use messages in the same place:
// β
Messages defined right where they're used
export const { messages } = defineMessages({
en: {
dashboard: {
title: "Dashboard",
welcome: "Welcome, {name}!",
},
},
ja: {
dashboard: {
title: "γγγ·γ₯γγΌγ",
welcome: "{name} γγγγγγγοΌ",
},
},
});
// Used immediately in the same component
const m = at(locale, messages);
return <h1>{t(m.dashboard.title)}</h1>;
// β Separate files, hard to maintain
// locales/en.json: { "dashboard.title": "Dashboard" }
// locales/ja.json: { "dashboard.title": "γγγ·γ₯γγΌγ" }
// No type safety, no IDE jumping
t("dashboard.title"); // β String literal, error-prone
const { t, m } = useI18n(messages)
- Simple & powerful!// Conditional locale loading
const getMessages = (locale: string) => {
switch (locale) {
case "en":
return at("en", messages);
case "ja":
return at("ja", messages);
default:
return at("en", messages);
}
};
const { messages } = defineMessages({
en: {
auth: {
login: {
title: "Sign In",
form: {
email: "Email Address",
password: "Password",
},
},
},
},
});
// Usage with full autocomplete
t(m.auth.login.form.email); // β Full IDE support!
We welcome contributions! Please see our Contributing Guide.
MIT Β© Jabelic
Made with β€οΈ for type-safe internationalization
FAQs
Type-safe internationalization tool for Next.js App Router with co-location and IDE code jumping
The npm package i18n-at receives a total of 36 weekly downloads. As such, i18n-at popularity was classified as not popular.
We found that i18n-at 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.