All skills
sergiodxa avatar

/frontend-internationalization-best-practices

@6eae8fd

Internationalization best practices for React Router framework mode using remix-i18next. Use when setting up locales, middleware, resource routes, or language switching.

Use this Skill: https://skilld.dev/gh/sergiodxa/agent-skills/frontend-internationalization-best-practices

This session only. Nothing lands on disk.

rulesuse-bound-t-in-loader.md

≈295 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Use the Bound t() in Loaders

Use the middleware instance’s bound t() in loaders and keep UI hooks for components.

Pattern

import { getInstance } from "~/middleware/i18next";

export async function loader({ context }: Route.LoaderArgs) {
  let t = getInstance(context).t;
  return { title: t("title"), description: t("description") };
}
import { useTranslation } from "react-i18next";

export default function Component() {
  let { t } = useTranslation();
  return <h1>{t("title")}</h1>;
}

Rules

Namespaced t()

If you need a specific namespace, use getFixedT with the current locale and namespace:

export async function loader({ context }: Route.LoaderArgs) {
  let i18n = getInstance(context);
  let t = i18n.getFixedT(i18n.language, "notFound");
  return { title: t("title") };
}

Rules

  1. Use the bound t() from getInstance(context) in loaders
  2. Use getFixedT(locale, namespace) when you need a specific namespace
  3. Use useTranslation in components for client rendering
  4. Avoid mixing different locales in the same loader

Source: SKILL.md on GitHub

1 warning8d5 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    The skill provides guidelines and patterns for implementing internationalization in React Router applications using remix-i18next. It demonstrates secure practices such as using Zod for input validation in resource routes to prevent directory traversal or arbitrary data access, and correctly configuring secure cookies for locale persistence. No security issues were identified.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

  • Runlayer7mo

    12/12 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 6eae8fd. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago

README badge

README badge for sergiodxa/agent-skills/frontend-internationalization-best-practices