Loading...
Loading...
Integrates Intlayer internationalization with React component. Use when the user asks to "setup React i18n", create a new translated component, use the "useIntlayer" hook, or configure providers.
npx skill4agent add aymericzip/intlayer-skills intlayer-react*.content.tsmyComponent.content.tsMyComponent.tsxuseIntlayert()src/components/MyComponent/myComponent.content.tsimport { t, type Dictionary } from "intlayer";
const content = {
// The 'key' must be unique and matches what you pass to useIntlayer()
key: "my-component",
content: {
text: t({
en: "Welcome",
fr: "Bienvenue",
es: "Hola",
// ... All other locales set in intlayer config file
}),
},
} satisfies Dictionary;
export default content;import { useIntlayer } from "react-intlayer";
const MyComponent = () => {
const content = useIntlayer("my-dictionary-key");
return (
<div>
<h1>
{/* Return react node */}
{content.text}
</h1>
{/* Return string (.value) */}
<img src={content.text.value} alt={content.text.value} />
</div>
);
};