feat(plugin-i18next)!: replace branded keys with native i18next types - #57
Open
RedStar071 wants to merge 3 commits into
Open
feat(plugin-i18next)!: replace branded keys with native i18next types#57RedStar071 wants to merge 3 commits into
RedStar071 wants to merge 3 commits into
Conversation
RedStar071
marked this pull request as draft
August 29, 2026 14:23
RedStar071
marked this pull request as ready for review
August 29, 2026 17:55
Ports wolfstar-project/stars-components#30 to `@wolfstar/plugin-i18next`. BREAKING CHANGE: `T`, `FT`, `resolveKey`, `resolveUserKey`, `TypedT`, `TypedFT`, `Value`, `Values` and `Difference` are removed. Keys are now plain strings typed through the `CustomTypeOptions` augmentation emitted by `@wolfstar/i18next-type-generator`, and `resolveKey(target, key, options)` becomes `getSupportedLanguageT(target)(key, options)`. `LocalePrefixKey` is no longer hardcoded to `commands/<file>:<key>`; it is now `${string}${LocaleSeparator}${string}`, with the new `LocaleSeparator` type read from i18next's `TypeOptions["nsSeparator"]`. `InternationalizationHandler#getT`, `getSupportedLanguageT`, `getSupportedUserLanguageT` and `fetchT` take an optional namespace and return a `TFunction<Ns>` bound to it.
RedStar071
force-pushed
the
feat/i18next-native-types
branch
from
August 29, 2026 17:56
e87af89 to
f8d4b1f
Compare
commit: |
…pers `getSupportedLanguageT` and `getSupportedUserLanguageT` take the key and its options right after the target, matching the call shape `resolveKey` and `resolveUserKey` had. The bound `TFunction` is still returned when no key is passed, and a non-default namespace is selected through the `ns` option, so the namespace parameter these helpers and `fetchT` briefly took is gone; `InternationalizationHandler#getT` keeps it.
`@wolfstar/http-framework-i18n` declared `lng` and `ns` on `TFunction`, and dropping that augmentation broke code reading the language off a bound function even though i18next still assigns it. Declares `lng`, `lngs`, `ns` and `keyPrefix`, matching what `getFixedT` sets at runtime.
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.
🔗 Linked issue
Backport of wolfstar-project/stars-components#30.
Note
This supersedes that PR.
@wolfstar/http-framework-i18n— the package it targets — is deprecatedin favour of
@wolfstar/plugin-i18next, so upstream #30 can be closed once this lands: the APIchanges it makes live here now, and consumers migrate through the plugin's migration guide instead
of upgrading that package.
🧭 Context
stars-componentsreplaced the hand-maintained branded-key helpers (T/FTand theresolve*functions) in
@wolfstar/http-framework-i18nwith i18next's own TypeScript support, where keys areplain strings typed through a
CustomTypeOptionsaugmentation.@wolfstar/plugin-i18nextmergesthat package with
@sapphire/plugin-i18next, so it still shipped the removed API and drifted fromupstream.
📚 Description
Removes the branded-key layer from
@wolfstar/plugin-i18nextand makes the translator helpersnamespace-aware, matching upstream. Keys are typed by the augmentation generated with
@wolfstar/i18next-type-generator;without it every helper still accepts plain strings, only untyped.
The generator package itself is not vendored here — it lives in
stars-componentsand is publishedto npm, so the README links to it instead. Everything else upstream #30 changed in
http-framework-i18nis covered by this PR, which is what makes that one redundant.Key changes
T('commands/ping:success')/FT<{ latency: number }>(...)CustomTypeOptionsresolveKey(target, key, options)getSupportedLanguageT(target, key, options)getT(locale), always the default namespacegetT(locale, namespace?)returningTFunction<Ns>LocalePrefixKey`commands/${string}:${string}``${string}${LocaleSeparator}${string}`, withLocaleSeparatorfromTypeOptions['nsSeparator']Removed exports:
T,FT,resolveKey,resolveUserKey,TypedT,TypedFT,Value,Values,Difference.getSupportedLanguageTandgetSupportedUserLanguageTkeep the call shaperesolveKeyandresolveUserKeyhad: the key and its options go right after the target, and the boundTFunctionisreturned only when no key is passed. A non-default namespace is selected through the
nsoption.The
TFunctionaugmentationhttp-framework-i18nshipped is kept for its metadata half —lng,lngs,nsandkeyPrefix, which i18next assigns on every functiongetFixedTreturns but doesnot type — so code reading the language off a bound function migrates untouched. Only the branded
T/FTcall signatures are gone.InternationalizationHandler#getTtakes an optional namespace and returns aTFunction<Ns>bound toit. The cached per-language functions are still used when no namespace is passed, so only an explicit
namespace goes through
i18next.getFixedT.The three test suites that relied on the branded keys were rewritten against the translator helpers,
with new cases covering the namespace-bound functions. The README gained a "Typed keys" section for
the generator and a "Migrating off
T/FT/resolve*" section mapping every removed export toits replacement.
Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.Confidence Score: 5/5
No blocking failure remains in the changed translation behavior.
The focused runtime checks, package test suite, and TypeScript typecheck completed successfully, and no actionable P0 or P1 finding remains.
What T-Rex did
Reviews (3): Last reviewed commit: "feat(plugin-i18next): declare the metada..." | Re-trigger Greptile