@refinest/i18n-core
v0.2.0
Published
Refinest: hierarchical i18n with fallback chain over i18next
Readme
@refinest/i18n-core
Hierarchical i18n for refinest, with a per-resource fallback chain over i18next.
Translation happens at render time, so switching language updates the whole UI live — no reload, no refetch.
Install
pnpm add @refinest/i18n-coreUsage
import { createI18n, createI18nextAdapter } from '@refinest/i18n-core';
const i18n = createI18n({
adapter: createI18nextAdapter({
defaultLocale: 'ru',
locales: ['ru', 'en'],
resources: { ru: ruBundle, en: enBundle },
fallbackLocale: 'en',
}),
});Key resolution
A key is resolved against the most specific namespace first and falls back outward, so a resource can override a shared string without copying the rest:
resources.<resource>.fields.<field>.label → fields.<field>.label → <the key itself>resolveKey implements that chain and is exported for callers that need to know which key won.
Main exports
createI18n/I18nFacade— the facade the React layer consumes.createI18nextAdapter— the default backend; swap it to use another i18n runtime.createResourceI18n/ResourceI18n— a resource-scoped view of the facade.resolveKey— the fallback-chain resolver, usable standalone.
License
MIT
