ITADN

Not able to change language

#37Closedadamgajzlerowicz 创建于 2023-10-12
I am trying to change the language, but still the value of `baseTranslation` is used. Am I dong something wrong? This is my implementation: ``` import { createI18n, localeFrom, browser } from '@nanostores/i18n' import { persistentAtom } from '@nanostores/persistent' import { fetchJson } from 'fetch-json' export const setting = persistentAtom<string | undefined>('locale', undefined) export const locale = localeFrom( setting, browser({ available: ['en', 'pl'], fallback: 'en', }), ) console.log(locale.get()) // logs en export const i18n = createI18n(locale, { async get(code) { console.log('hello') // is never called if (code === 'pl') { return Promise.resolve({}) } return fetchJson.get(`/translations/${code}.json`) }, }) export const navigation = i18n('navigation', { app: 'Aplikacja', }) console.log(navigation.value?.app) // logs polish translation ``` Thank you!
关闭于 2024-07-28 5 条评论