agentleFS
aymericzipaymericzip/intlayer/.claude/skills/intlayer-content/SKILL.md

intlayer-content

Skill863 starsChanged 13 days agoApache-2.0View on GitHub

Define rich content structures using Intlayer content nodes. Use when the user asks to "create translations", "handle pluralization", "use markdown in content", or implement "conditional content".

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Avoid using t() when the content is identical across locales or does not need internationalization:

    line 35
  2. Very specific:

    Avoid using syntax like myLabel={isLoggedIn ?

    line 230
  3. Very specific:

    Prefer using cond instead, like myLabel={content.welcomeGoodbye(isLoggedIn)}.

    line 231

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Intlayer Content Nodes

Define rich and dynamic content using Intlayer functions. Use the reference below for each node type.

Translation (t)

Define multilingual content mapped to locales.

Doc

import { t } from "intlayer";

const content = t({
  en: "Hello",
  fr: "Bonjour",
  es: "Hola",
});

Avoid using t() when the content is identical across locales or does not need internationalization:

// Avoid
myKey: t({
  en: "Intlayer",
  fr: "Intlayer",
});

// Prefer
myKey: "Intlayer";

Find locales to declare in config file. Supported configuration files:

  • intlayer.config.{ts|js|cjs|mjs|json|json5|jsonc|md|mdx|yml|yaml}
  • .intlayerrc

Enumeration (enu)

Map content to custom numeric values or ranges (<5, >=10). For grammatical plural forms, use plural instead.

Doc

import { enu } from "intlayer";

const carCount = enu({
  "0": "No cars",
  "1": "One car",
  ">1": "Multiple cars",
  fallback: "Unknown amount",
});

Plural (plural)

Select the grammatical plural form from a count, using the CLDR categories (zero, one, two, few, many, other) of the active locale. other is required and used as fallback.

Doc

import { plural, t } from "intlayer";

const totalOpenings = t({
  en: plural({
    one: "{{count}} opening",
    other: "{{count}} openings",
  }),
  ru: plural({
    one: "{{count}} вакансия",
    few: "{{count}} вакансии",
    many: "{{count}} вакансий",
    other: "{{count}} вакансий",
  }),
});

// Usage: totalOpenings(3) or totalOpenings({ count: 3, name: "Alice" })

plural must be the leaf: wrap it in t(), never put t() inside plural().

Condition (cond)

Define content based on a boolean condition.

Doc

import { cond } from "intlayer";

const isLoggedIn = cond({
  true: "Welcome back!",
  false: "Please log in",
  fallback: "Status unknown", // Optional
});

Markdown (md)

Define rich text using Markdown syntax.

Doc

import { md } from "intlayer";

const article = md("# Title\n\nSome **bold** text.");

HTML (html)

Define HTML content, optionally with custom components.

Doc

import { html } from "intlayer";

const richText = html("<p>Hello <strong>World</strong></p>");

Nesting (nest)

Reuse content from another dictionary.

Doc

import { nest } from "intlayer";

// Reference entire dictionary
const fullRef = nest("other_dictionary_key");

// Reference specific path
const partialRef = nest("other_dictionary_key", "path.to.value");

Function Fetching

Execute logic to generate content (synchronous or asynchronous).

Doc

const computed = () => `Current time: ${new Date().toISOString()}`;

const fetched = async () => {
  const data = await fetch("/api/data").then((res) => res.json());
  return data.message;
};

Insertion (insert)

Define dynamic content with variables.

Doc

import { insert } from "intlayer";

const welcome = insert("Hello {{name}}!");

File (file)

Reference external files as content.

Doc

import { file } from "intlayer";

const myFile = file("./path/to/file.txt");

Gender (gender)

Define content based on gender ('male', 'female', etc.).

Doc

import { gender } from "intlayer";

const greeting = gender({
  male: "Welcome sir",
  female: "Welcome madam",
  fallback: "Welcome",
});

Select (select)

Map any string value (status, plan, role…) to content: the equivalent of an ICU select or a switch. Without fallback, only the declared cases are type-accepted.

Doc

import { select } from "intlayer";

const publishStatus = select({
  draft: "This post is a draft",
  published: "This post is live",
  fallback: "Unknown status", // Optional
});

// Usage: publishStatus(post.status)

Prefer select() over indexing a plain object (content[status]): dynamic property access prevents the compiler from pruning and minifying the content.

Choosing a node by discriminant

Avoid using syntax like myLabel={isLoggedIn ? content.welcome : content.goodbye}. Prefer using cond instead, like myLabel={content.welcomeGoodbye(isLoggedIn)}.

Avoid using syntax like content[myKey]. Prefer using select instead, like content.selectContent(myKey).

DiscriminantNode
A count (grammar)plural()
A number / custom rangesenu()
A booleancond()
A gendergender()
Any other string valueselect()

Example Directory Structure (react)

src/
├── components/
│   ├── MyComponent/
│   │   ├── index.content.ts          # Content declaration
│   │   └── index.tsx                 # Component
│   ├── myOtherComponent.content.ts   # Content declaration
│   └── MyOtherComponent.tsx          # Component

Content Templates

TypeScript (.content.ts)

import { t, type Dictionary } from "intlayer";

const content = {
  key: "my-component-key",
  content: {
    title: "...",
  },
} satisfies Dictionary;

export default content;

TypeScript with React (.content.tsx)

import { t, type Dictionary } from "intlayer";
import { ReactNode } from "react";

const content = {
  key: "my-component-key",
  content: {
    title: <>My React Node</>,
  },
} satisfies Dictionary;

export default content;
{
  "key": "my-component-key",
  "content": {
    "title": "..."
  }
}
import { t } from "intlayer";

/** @type {import('intlayer').Dictionary} **/
const content = {
  key: "my-component-key",
  content: {
    title: "...",
  },
};

export default content;

Content declaration combination

Nodes can be imbricated for complex logic.

import {
  cond,
  enu,
  file,
  gender,
  html,
  insert,
  md,
  nest,
  plural,
  select,
  t,
  type Dictionary,
} from "intlayer";

const content = {
  key: "test",
  title: "Test component content",
  description:
    "Content declarations for the Test component, including examples of plurals, conditions, gender-specific messages, string-based selections, dynamic insertions, markdown, html, file-based content and nested dictionaries used for demonstration and testing purposes.",
  content: {
    baseContent: "Intlayer", // Content that no need to be i18n
    welcomeMessage: t({
      en: "Welcome to our application",
      "en-GB": "Welcome to our application",
      fr: "Bienvenue dans notre application",
      es: "Bienvenido a nuestra aplicación",
      // ... All other locales set in intlayer config file
    }),
    numberOfCar: enu({
      // Check all conditions in other
      "<-1": "Less than minus one car",
      "-1": "Minus one car",
      "0": "No cars",
      "1": "One car",
      ">19": "Many cars",
      ">5": "Some cars", // Will never will triggered, because >5 is included between 1 and >19
      fallback: "Fallback value", // Optional but avoid undefined type
    }),
    myCondition: cond({
      true: "my content when it's true",
      false: "my content when it's false",
      fallback: "my content when the condition fails", // Optional but avoid undefined type
    }),
    myGender: gender({
      male: "my content for male users",
      female: "my content for female users",
      fallback: "my content when gender is not specified", // Optional but avoid undefined type
    }),
    mySelect: select({
      draft: "my content when the status is draft",
      published: "my content when the status is published",
      fallback: "my content for any other status", // Optional but avoid undefined type
    }),
    myMultilingualSelect: select({
      pending: t({
        en: "Pending approval",
        fr: "En attente d’approbation",
        es: "Pendiente de aprobación",
      }),
      approved: t({
        en: "Approved",
        fr: "Approuvé",
        es: "Aprobado",
      }),
      rejected: t({
        en: "Rejeté",
        fr: "Rejeté",
        es: "Rechazado",
      }),
      fallback: t({
        en: "Unknown status",
        fr: "Statut inconnu",
        es: "Estado desconocido",
      }),
    }),
    myPlural: plural({
      zero: "No items",
      one: "{{count}} item",
      other: "{{count}} items",
    }),
    myMultilingualPlural: t({
      en: plural({
        zero: "No books",
        one: "{{count}} book",
        other: "{{count}} books",
      }),
      fr: plural({
        zero: "Aucun livre",
        one: "{{count}} livre",
        other: "{{count}} livres",
      }),
      es: plural({
        zero: "Ningún libro",
        one: "{{count}} libro",
        other: "{{count}} libros",
      }),
    }),
    myInsertion: insert(
      "Hello, my name is {{name}} and I am {{age}} years old!"
    ),
    myMultilingualInsertion: insert(
      t({
        ar: "مرحبا, اسمي {{name}} وأنا {{age}} سنة!",
        de: "Hallo, mein Name ist {{name}} und ich bin {{age}} Jahre alt!",
        en: "Hello, my name is {{name}} and I am {{age}} years old!",
        "en-GB": "Hello, my name is {{name}} and I am {{age}} years old!",
      })
    ),
    myTextFile: file("./test.txt"), // File helps to know where is located the file
    subContent: {
      contentNumber: 0,
      contentString: "string",
      contentBoolean: true,
    },
    fullNested: nest("code"),
    // References a specific nested value:
    partialNested: nest("code", "title"),
    myMarkdown: md("## My title \n\nLorem Ipsum"),
    myMarkdownFile: md(file("./test.md")),
    multilingualMarkdown: t({
      en: md("## test en"),
      fr: md("## test fr"),
      es: md("## test es"),
      "en-GB": md("## test en-GB"),
    }),
    myHTML: html("<h2>My title</h2><p>Lorem Ipsum</p>"),
    myHTMLFile: html(file("./test.html")),

    arrayContent: ["string", "string2", "string3"],
    arrayOfObject: [
      {
        name: "item1",
        description: "description1",
      },
      {
        name: "item2",
        description: "description2",
      },
    ],
    objectOfArray: {
      array: ["item1", "item2", "item3"],
      object: {
        name: "object name",
        description: "object description",
      },
    },
  },
  tags: ["test", "test page", "select", "plural"],
} satisfies Dictionary;

export default content;

Type validation of dictionary

Dictionary<{ title: string; description?: string }>; // Generic describing content type for formatted data (metadata, etc)

Key Dictionary Fields for AI Management

Core Metadata

  • key: The identifier for the dictionary (e.g., about-page-meta). AI can ensure consistent naming conventions.
  • title: A human-readable name for identification in the CMS or editor.
  • description: Provides context for the dictionary. AI uses this to understand the purpose and generate better translations or content.
  • tags: Categorization strings (e.g., metadata, SEO) to help organize and filter dictionaries.

Content & Localization

  • locale: Specifies the language of the content for a per-locale file
  • contentAutoTransformation: A toggle to automatically convert raw strings into specialized formats like Markdown, HTML, or Insertions (variables).
  • fill: An instruction indicating whether the dictionary should be automatically populated by AI/automation tools.

Behaviorals Settings

  • priority: A numeric value used to resolve conflicts during merge of dictionaries under a same key.
  • importMode: Defines how content is loaded (static, dynamic, or fetch). AI can recommend the best mode based on performance needs.
  • location: Controls CMS synchronization (hybrid, remote, local). AI can manage where the source of truth resides.
  • schema: string that use zod schema declared in config file to validate data

References

Content Nodes

  • Content File
  • Translation
  • Enumeration
  • Plural
  • Condition
  • Gender
  • Select
  • Insertion
  • Markdown
  • HTML
  • Nesting
  • File
  • Function Fetching

Packages

  • Exports intlayer package

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.