mcpField
I
intlayer-react

intlayer-react

github.com/aymericzipDevelopment562 installsUpdated 6w ago
Repository

About intlayer-react

intlayer-react is a usage skill for Intlayer in React projects, covering component-adjacent content declarations and hook-based access. It is for developers building localized React components.

Key features

  1. 01Declare content dictionaries beside components
  2. 02Define translations with t()
  3. 03Read content through the useIntlayer hook
  4. 04Cover multiple React application setups

Use cases

  1. 01Add multilingual content to React components
  2. 02Read declared dictionaries in component implementations
  3. 03Refer to Intlayer setup for different React environments

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aymericzip/intlayer-skills --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