
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
@fw-components/localize
Advanced tools
A localization utility built on top of lit-localize, providing simplified message extraction and runtime locale switching for web applications.
The package provides two main components:
CLI Tool: A command-line utility (fw-localize
) that extracts localizable messages from your source code and generates translation files.
Runtime Library: Functions for loading translations and switching between locales in your application.
The localization workflow consists of:
msg()
// Example locales/es.json
{
"Hello": "Hola",
}
Extract messages from your source files:
npx fw-localize extract
Configuration is specified in a localize.json
file:
{
"sourceLocale": "en",
"targetLocales": ["es", "fr", "de"],
"tsConfig": "./tsconfig.json",
"output": {
"mode": "runtime",
"outputDir": "./locales"
},
"interchange": {
"format": "json"
}
}
import { configureLocalization, msg } from '@fw-components/localize';
// Configure localization
const { getLocale, setLocale } = configureLocalization({
sourceLocale: 'en',
targetLocales: ['es', 'fr', 'de'],
loadLocale: (locale) => import(`./locales/${locale}.js`)
});
// Use in your components
function renderGreeting(name) {
return html`
<h1>${msg("Hello")}</h1>
`;
}
// Switch locale
await setLocale('es');
Use the msg()
function to mark text for translation:
// For static strings
msg("Hello world")
// For strings with expressions
msg(`Hello ${username}`)
For more advanced usage and options, refer to the lit-localize documentation.
FAQs
Localizer built on top of lit-localize
We found that @fw-components/localize demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.