I18n

From redis/RedisInsight · View interactive version

I18n is an AI agent skill from the GitHub repository redis/RedisInsight. Internationalization conventions for the RedisInsight UI (i18next). Use when adding or changing user-facing strings under redisinsight/ui/**, editing the locale files (en.json/bg.json), translating API errors or notifications, or when the user mentions i18n, translations, locales, i18next, or <Trans

How to use this skill

Skill file

Internationalization (i18n)

RedisInsight UI is localized with i18next + react-i18next. English (en)

is the source of truth; Bulgarian (bg) is the second locale.

Where things live

Choosing the API

| Use | When |

| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| useTranslation() hook → t | Inside a React component rendered in the tree. |

| i18n.t singleton (import i18n from 'uiSrc/i18n') | Non-React code: redux thunks, factories, utils, message builders (e.g. error-messages.tsx, success-messages.tsx, INFINITE_MESSAGES). These run outside React, so the hook is unavailable. |

| <Trans> (from uiSrc/i18n) | A message with mid-sentence markup/links — bold spans, inline <a>. Keys use component tags: "… <consoleLink>Cloud console</consoleLink> …" + components={{ consoleLink: <a … /> }}. |

Usage examples

Hook — inside a React component:

import { useTranslation } from 'uiSrc/i18n';

const AddKeyButton = () => {
  const { t } = useTranslation();
  return <PrimaryButton>{t('browser.addKey.button.submit')}</PrimaryButton>;
};

Singleton — non-React code (thunks, factories, utils):

import i18n from 'uiSrc/i18n';

export const deletedKeyMessage = () => ({
  title: i18n.t('browser.deletedKey.title'),
});

Interpolation — pass values; reference {{vars}} in the string:

// en.json: "browser.deletedKey.message": "{{name}} has been deleted."
t('browser.deletedKey.message', { name: keyName });

<Trans> — mid-sentence markup or links (map tags to components):

import { Trans } from 'uiSrc/i18n';

// en.json: "browser.docs": "See the <docsLink>documentation</docsLink> for details."
<Trans
  i18nKey="browser.docs"
  components={{
    docsLink: <a href={DOCS_URL} target="_blank" rel="noreferrer" />,
  }}
/>;
// interpolation still works alongside components via `values={{ … }}`

Backend error resource — interpolated automatically:

// Response: { errorCode: 11200, resource: { databaseId: 'abc' } }
// en.json:  "api.error.code.11200.message": "Database {{databaseId}} already exists."
// getTranslatedApiError() fills {{databaseId}} from response.data.resource — no extra code.

Plurals

Use i18next's native count-based plurals — never a hand-rolled isPlural branch with

.single/.plural keys.

need more forms — _few, _many — but en/bg only use _one/_other).

t('key', { count }) or <Trans i18nKey="key" count={n} …/>.

types resolve it from the _one/_other entries.

fragment — word order, agreement, and the number of plural forms vary by language.

i18n:extract doesn't prune — delete the orphan so en/bg parity holds.

// en.json:
//   "workbench.runConfirm.body_one":   "…This command is part of…"
//   "workbench.runConfirm.body_other": "…These commands are part of…"
<Trans i18nKey="workbench.runConfirm.body" count={commands.length} components={{ bold }} />

Keys

Namespaces

The top-level segment says where a string belongs. There are two kinds:

1. Cross-cutting (by source), not tied to a page:

2. By page/module — most UI copy. Top-level = the feature (mirror the folder in

redisinsight/ui/src/pages/<page> → <page>.*); nest by section/component; the leaf

describes the string. A page owns its keys; only promote to common.* when genuinely shared.

| Namespace | Module (pages/…) | Example keys |

| ------------- | ------------------ | ------------------------------------------------------------------------------------------------------------- |

| browser.* | browser | browser.keyList.empty, browser.addKey.title, browser.filter.placeholder, browser.addKey.button.submit |

| workbench.* | workbench | workbench.editor.runTooltip, workbench.results.empty |

| rdi.* | rdi | rdi.pipeline.deploy.title, rdi.config.button.deploy |

| settings.* | settings | settings.section.general, settings.language.title |

Common leaf segments: *.title, *.description, *.label, *.placeholder, *.tooltip,

and *.button.<action> for action labels (keep them distinct from titles/descriptions,

e.g. browser.addKey.button.submit, api.error.code.11024.button.signIn).

Backend error codes

The backend ships a stable errorCode on every user-facing error (see

redisinsight/api/src/constants/custom-error-codes.ts). The UI translates by that code:

utils/apiResponse.ts look up

api.error.code.<n>.message / .title and fall back to the backend text when the key is absent.

Adding or editing a translation

  1. Add the key + English value to en.json and the same key to bg.json (translated, or empty to defer). Keep both sorted and in parity.
  2. Reference it: t('my.key') / i18n.t('my.key') / <Trans i18nKey="my.key" …/>.
  3. For dynamic values, pass values (interpolation) or resource (backend errors).
  4. Run npm run i18n:extract to sync/sort, and npm run i18n:check to catch duplicate keys.
  5. npm run type-check (new literal keys must resolve) and npm run lint:ui.

Tooling

Do / Don't

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.