With a nanostores-like interface:
const { locale, translations, t, useTranslations } = defineTranslationsConfig(...)
locale.listen((locale) => {
console.log('new locale set:', locale)
})
translations.listen((translations) => {
valibot.setGlobalMessage((issue) => t(translations.errors.generic, { input: issue.message }))
})
console.log(
t(
await (translations.get())
.article
.heading
.publishedBy,
{ ... }
)
)
const Component = () => {
const heading = useTranslations(translations, 'article.heading')
// or like it is now
const heading = useTranslations('article.heading')
return <span>{t(heading.publishedBy, { name })}</span>
}
With this interface, it's possible to remove the get* functions and builders, greatly simplifying both the t package and the adapters (~> also allowing the removal of the setup parameter).
With a nanostores-like interface:
With this interface, it's possible to remove the
get*functions and builders, greatly simplifying both thetpackage and the adapters (~> also allowing the removal of thesetupparameter).