mcpField
I
intlayer-react

intlayer-react

github.com/aymericzipDevelopment86142 installsUpdated today
Repository

About intlayer-react

A skill for building translated React components with Intlayer. It uses component-adjacent content declarations and the `useIntlayer` hook to connect dictionaries to components.

Key features

  1. 01Component-level content declarations
  2. 02Translation dictionaries with `t()`
  3. 03`useIntlayer` hook usage
  4. 04React environment references

Use cases

  1. 01Adding translated content to a React component
  2. 02Organizing translations beside component code
  3. 03Connecting a dictionary to a component

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aymericzip/intlayer --skill intlayer-react

After installing, type/intlayer-reactin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

LICENCE.md
references/
environment_create-react-app.md
environment_lynx-and-react.md
environment_react-native-and-expo.md
environment_tanstack-start.md
environment_vite-and-react_react-router-v7-fs-routes.md
environment_vite-and-react_react-router-v7.md
environment_vite-and-react.md
packages_intlayer_exports.md
packages_react-intlayer_exports.md
packages_react-intlayer_IntlayerProvider.md
packages_react-intlayer_MarkdownRenderer.md
packages_react-intlayer_t.md
packages_react-intlayer_useDictionary.md
packages_react-intlayer_useI18n.md
packages_react-intlayer_useIntlayer.md
packages_react-intlayer_useLocale.md

Details

From the project README

Intlayer React 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 React components that use them.

Workflow

To create a translated component, you need two files:

  1. Declaration: A content file (e.g., myComponent.content.ts) defining the dictionary.
  2. Implementation: A React component (e.g., MyComponent.tsx) using the useIntlayer hook.
1. Declare Content

Create a content file using t() for translations. File: src/components/MyComponent/myComponent.content.ts

import { 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;

Intlayer React Usage

Setup

useIntlayer Hook

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>
  );
};

References

Environments
Packages

Comments

Markdown supported