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.

rulesentry-client-init.md

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

Initialize i18next on the Client

Use the HTML lang attribute as the client detection source and load namespaces from /api/locales.

Pattern

// app/entry.client.tsx
import Fetch from "i18next-fetch-backend";
import i18next from "i18next";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
import { I18nextProvider, initReactI18next } from "react-i18next";
import { HydratedRouter } from "react-router/dom";
import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";

async function main() {
  await i18next
    .use(initReactI18next)
    .use(Fetch)
    .use(I18nextBrowserLanguageDetector)
    .init({
      fallbackLng: "en",
      detection: { order: ["htmlTag"], caches: [] },
      backend: { loadPath: "/api/locales/{{lng}}/{{ns}}" },
    });

  startTransition(() => {
    hydrateRoot(
      document,
      <I18nextProvider i18n={i18next}>
        <StrictMode>
          <HydratedRouter />
        </StrictMode>
      </I18nextProvider>,
    );
  });
}

main().catch((error) => console.error(error));

Rules

  1. Detect locale from htmlTag only (server already decided)
  2. Use /api/locales/{{lng}}/{{ns}} for resource loading
  3. Keep fallbackLng aligned with middleware

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