Files
suaveplan/packages/ui/react/react-auth/src/translations/en-gb.md
2026-05-27 23:47:53 +01:00

2.5 KiB

en-gb

Purpose

en-gb.ts ships the British-English string table consumed by the Wave 2 forms and Wave 3 page components. The file also defines the canonical AuthTranslationPack shape (broken into 10 named sub-interfaces — login, register, forgotPassword, resetPassword, emailVerification, profile, validation, errors, success, loading — so every locale conforms to the same structural contract). The default-exported object literal serves as both the production string source and the structural baseline against which cy-gb and zh-cn are checked at compile time. No runtime code; pure data.

Features

  • AuthTranslationPack interface (and 10 sub-interfaces) — structural shape every locale conforms to.
  • Default-exported object literal with British-English copy across 10 functional groups.
  • Compile-time pin: a missing or extra key in any locale fails tsc.

Usage: Basic

import enGb from "@suaveplan/react-auth";

console.log(enGb.auth.login.title); // "Sign In"

Usage: Advanced

Resolve a translation key from the active locale by walking the typed map:

import { authTranslations, type AuthTranslationPack } from "@suaveplan/react-auth";

type LocaleKey = "en-gb" | "cy-gb" | "zh-cn";

function tLogin(locale: LocaleKey, key: keyof AuthTranslationPack["auth"]["login"]) {
    return authTranslations[locale].auth.login[key];
}

API Reference

  • interface AuthLoginStrings / AuthRegisterStrings / AuthForgotPasswordStrings / AuthResetPasswordStrings / AuthEmailVerificationStrings / AuthProfileStrings / AuthValidationStrings / AuthErrorStrings / AuthSuccessStrings / AuthLoadingStrings — section interfaces.
  • interface AuthStrings — aggregate of the section interfaces.
  • interface AuthTranslationPack — { auth: AuthStrings }.
  • default — the British-English translation pack.

Implementation Notes

The interface is defined here (not in types/) because it co-locates with the canonical source-of-truth string set. The compile-time conformance check on cy-gb and zh-cn works because each locale annotates its module-level constant with : AuthTranslationPack; if a section is missing or a typo introduces an extra field, tsc fails the typecheck gate. The as const pattern is deliberately avoided here — using a structural interface (not literal narrowing) lets translators ship variant copy without retyping the schema, and prevents the cross-locale assignment errors seen in upstream's first port.