Repository navigation
feat: ship Spanish and Portuguese for every built-in code, and accept i18next's t as-is - #44
Merged
Merged
Conversation
… i18next's t as-is
describe(code, params, t) already looked each code up in your i18next as
errors.<code>, but the package shipped no translations and the README only
mentioned it in passing, so it read as English-only.
- locales/es.json and locales/pt.json: all 24 built-in codes as nested
i18next JSON with {{name}} placeholders, exported as
@gainratio/errors/locales/<lang>.json. Data only, no new runtime code,
still zero dependencies.
- New Translator type for describe's t. TFunction is unchanged and still
fits, but i18next's own t and getFixedT() now type-check without a
wrapper under exactOptionalPropertyTypes.
- README: one line up top, and a "Show errors in the user's language"
section whose example and output a test runs against real i18next.
- test/locales.test.ts: every code present in es and pt, placeholders
match the English, pt-BR -> pt and unknown -> English in real i18next,
the package exports the files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GRdR6TpVeKiz2Tr4hEGsEo
Northstar punch list for #44. - i18next HTML-escapes values by default, so "a/b" came back as "a/b" in the translated sentence and the Problem Details title. The example and docs now set escapeValue: false; a test pins both the plain result and the escaped default. - Reworded five es and six pt sentences that read as calques. - Docs say the pt file is Brazilian Portuguese; GETTING_STARTED lists locales/ and the second README example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GRdR6TpVeKiz2Tr4hEGsEo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim touched: "one sentence a person can read" — now in the user's language. The code and the Problem Details
typestay fixed in every language.Why
describe(code, params, t)already looks codes up in your i18next aserrors.<code>, but nothing shipped in another language and the README mentioned it once, deep in "Try it". Harish read it as English-only.What
locales/es.json,locales/pt.json: all 24 built-in codes (core + ai + bundle + starter), nested i18next JSON with{{name}}placeholders, exported as@gainratio/errors/locales/<lang>.json. Data only. Still zero runtime/peer dependencies (i18nextis a devDependency for tests).Translatortype fordescribe'st.TFunctionis unchanged and still accepted. Before this, passing i18next's ownt/getFixedT()failed to type-check underexactOptionalPropertyTypes(TS2769), which is why consumers wrote adapters.examples/languages.mjs) and its pasted output are executed bytest/readme.contract.test.tsagainst real i18next. API.md and ARCHITECTURE.md updated. CHANGELOG comes from thisfeat:commit via release-please.Evidence
pnpm gateerrors.ai.provider.out_of_creditsfrom es.jsonhas a sentence for every built-in code(diff- "errors.ai.provider.out_of_credits"),describes every registered code in Spanish and Portuguese{{field}}->{field}in pt.json{{name}}stylegetFixedTwithout the new typepnpm typecheckTS2769 x9node languages.mjsprints es / pt-BR / fr->en correctly;tsc --strict --exactOptionalPropertyTypesacceptsdescribe(..., i18next.t)Back-compat: no existing test changed except the README contract (one new section added to the ordered list, "Try it" check generalized to two examples). English output for every call without
tis unchanged.Not done here: Spanish/Portuguese wording is not reviewed by a native speaker; a test checks keys and placeholders only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GRdR6TpVeKiz2Tr4hEGsEo