Skip to content

aymericzip/intlayer-skills / skills/intlayer-usage

intlayer-usage

Verified

Provides general guidelines for using Intlayer in any project. Use when the user asks to "get started with Intlayer", "declare content files", or understand the "project structure" for internationalization.

FileKindSize
LICENCE.mdmarkdown10.7 KB
SKILL.mdskill md3.6 KB
references/concept_how-works-intlayer.mdmarkdown28.7 KB
references/concept_per-locale-file.mdmarkdown7.6 KB
references/get-started.mdmarkdown26.6 KB
references/packages_intlayer_comparePaths.mdmarkdown5.0 KB
references/packages_intlayer_exports.mdmarkdown12.4 KB
references/packages_intlayer_getCanonicalPath.mdmarkdown3.4 KB
references/packages_intlayer_getConfiguration.mdmarkdown4.1 KB
references/packages_intlayer_getDictionary.mdmarkdown4.9 KB
references/packages_intlayer_getDictionaryAsync.mdmarkdown6.3 KB
references/packages_intlayer_getEnumeration.mdmarkdown3.3 KB
references/packages_intlayer_getHTMLTextDir.mdmarkdown2.3 KB
references/packages_intlayer_getIntlayer.mdmarkdown8.7 KB
references/packages_intlayer_getIntlayerAsync.mdmarkdown6.8 KB
references/packages_intlayer_getLocale.mdmarkdown1.1 KB
references/packages_intlayer_getLocaleLang.mdmarkdown1.9 KB
references/packages_intlayer_getLocaleName.mdmarkdown3.5 KB
references/packages_intlayer_getLocalizedPath.mdmarkdown6.8 KB
references/packages_intlayer_getLocalizedUrl.mdmarkdown9.3 KB
references/packages_intlayer_getMultilingualUrls.mdmarkdown8.7 KB
references/packages_intlayer_getPathWithoutLocale.mdmarkdown1.6 KB
references/packages_intlayer_getPrefix.mdmarkdown6.0 KB
references/packages_intlayer_getTranslation.mdmarkdown3.4 KB
references/packages_intlayer_validatePrefix.mdmarkdown1.0 KB
references/packages_react-intlayer_exports.mdmarkdown13.7 KB
references/packages_vite-intlayer_exports.mdmarkdown6.0 KB
references/packages_vite-intlayer_intlayer.mdmarkdown6.0 KB
references/packages_vite-intlayer_intlayerCompiler.mdmarkdown4.2 KB
references/packages_vite-intlayer_intlayerMinify.mdmarkdown3.9 KB
references/packages_vite-intlayer_intlayerProxy.mdmarkdown7.0 KB
references/packages_vite-intlayer_intlayerPrune.mdmarkdown4.7 KB
references/why.mdmarkdown58.2 KB

references/packages_intlayer_getEnumeration.md

View on GitHub
---
createdAt: 2025-08-23
updatedAt: 2026-09-27
priority: 5
title: getEnumeration Function Documentation | intlayer
description: "Use getEnumeration (alias enu) to pick the content matching a quantity from an enumeration object, based on its conditions."
keywords:
  - getEnumeration
  - translation
  - Intlayer
  - intlayer
  - Internationalization
  - Documentation
  - Next.js
  - JavaScript
  - React
slugs:
  - doc
  - packages
  - intlayer
  - getEnumeration
history:
  - version: 5.5.10
    date: 2025-06-29
    changes: "Init history"
author: aymericzip
---

# Documentation: `getEnumeration` Function in `intlayer`

## Description

The `getEnumeration` function (also aliased as `enu`) retrieves content corresponding to a specific quantity based on predefined conditions in an enumeration object. The conditions are defined as keys, and their priority is determined by their order in the object.

For more details on how to declare enumerations, see the [Enumeration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/enumeration.md).

- [Enumeration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/enumeration.md)

## Parameters

- `enumerationContent: QuantityContent<Content>`
  - **Description**: An object where keys represent conditions (e.g., `<=`, `<`, `>=`, `=`) and values represent the corresponding content. The order of keys defines their matching priority.
  - **Type**: `QuantityContent<Content>`
    - `Content` can be any type.

- `quantity: number`
  - **Description**: The numeric value used to match against the conditions in `enumerationContent`.
  - **Type**: `number`

## Returns

- **Type**: `Content`
- **Description**: The content corresponding to the first matching condition in the `enumerationContent`. If no match is found, it defaults to handling based on the implementation (e.g., error or fallback content).

## Example Usage

### Basic Usage

```typescript codeFormat={["typescript", "esm", "commonjs"]}
import { getEnumeration } from "intlayer";

const content = getEnumeration(
  {
    "<=-2.3": "You have less than -2.3",
    "<1": "You have less than one",
    "2": "You have two",
    ">=3": "You have three or more",
  },
  2
);

console.log(content); // Output: "You have two"
```

### Priority of Conditions

```typescript codeFormat={["typescript", "esm", "commonjs"]}
import { getEnumeration } from "intlayer";

const content = getEnumeration(
  {
    "<4": "You have less than four",
    "2": "You have two",
  },
  2
);

console.log(content); // Output: "You have less than four"
```

## Edge Cases

- **No Matching Condition:**
  - If no condition matches the provided quantity, the function will either return `undefined` or handle the default/fallback scenario explicitly.

- **Ambiguous Conditions:**
  - If conditions overlap, the first matching condition (based on object order) takes precedence.

- **Invalid Keys:**
  - The function assumes that all keys in `enumerationContent` are valid and parsable as conditions. Invalid or improperly formatted keys may lead to unexpected behavior.

- **TypeScript Enforcement:**
  - The function ensures that the `Content` type is consistent across all keys, allowing for type safety in the retrieved content.

## Notes

- The `findMatchingCondition` utility is used to determine the appropriate condition based on the given quantity.
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall