aymericzip/intlayer-skills / skills/intlayer-vanilla
intlayer-vanilla
VerifiedIntegrates Intlayer internationalization with plain JavaScript / TypeScript (no UI framework). Use when the user asks to "setup Vanilla JS i18n", translate a static HTML page, use "useIntlayer" without a framework, or switch locale in a vanilla application.
Intlayer Vanilla JS Usage
Core Philosophy
Intlayer promotes Component-Level Content Declaration. Instead of a massive global translation file, content is declared in *.content.ts files adjacent to the scripts that use them.
vanilla-intlayer mirrors the react-intlayer API without depending on a UI framework: a pub/sub singleton plus callback-based helpers.
Declare Content
File: src/app.content.ts
import { t, type Dictionary } from "intlayer";
const content = {
key: "app",
content: {
title: t({
en: "Welcome",
fr: "Bienvenue",
es: "Hola",
}),
},
} satisfies Dictionary;
export default content;
Setup
- Vite and Vanilla JS (bundled app)
- Vanilla JS (no bundler, standalone script generated by
intlayer standalone)
Call installIntlayer() before any content is rendered.
useIntlayer
useIntlayer(key, locale?) returns the content directly. Chain .onChange() to re-render when the locale changes.
import { useIntlayer } from "vanilla-intlayer";
const title = document.querySelector("h1")!;
const content = useIntlayer("app").onChange((newContent) => {
title.textContent = String(newContent.title);
});
title.textContent = String(content.title);
// Native attributes: use `.value`
// image.alt = content.title.value;
Without a bundler, read the same helpers from the globals of the standalone bundle:
window.VanillaIntlayerandwindow.Intlayer.
useLocale
import { useLocale } from "vanilla-intlayer";
const { locale, availableLocales, setLocale, subscribe } = useLocale();
const unsubscribe = subscribe((newLocale) => {
document.documentElement.lang = newLocale;
});
setLocale("fr");
Compiler
The Intlayer Compiler can extract all your content keys from your components, using one CLI command (npx intlayer extract) or automatically at app build.
References
Environments
Concepts
Packages
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |