-
Hi! I am currently using this project in my first real application. I like to load locales for namespaces so that each larger route could have its own sandbox for locales. An idea was therefor to use the Remix inspired import {
loadNamespaceAsync
} from "../i18n/i18n-util.async"
export async function loader() {
await loadNamespaceAsync("de", "customer")
return {}
} import type { NamespaceCustomerTranslation } from "../../types.js"
const de_customer = {
address: "Kundenanschrift"
} satisfies NamespaceCustomerTranslation
export default de_customer According to the network monitoring a file is being downloaded correctly. I was not liking the react-adapter//context approach so I thought how easy a custom adapter would be. Unfortunately it seems to be a little more tricky than I imagined... The most trivial case for me I could imagine was to initialize const msgs = i18nObject("de")
console.log("Translated:", msgs.customer.address()) This seems to work in the browser but ESLint is not happy about calling on an unsafe object:
That's the config I am using: {
"esmImports": true,
"typesFileName": "types",
"$schema": "https://unpkg.com/[email protected]/schema/typesafe-i18n.json"
} This is the content of the generated export type Namespaces =
| 'contracts'
| 'customer'
type DisallowNamespaces = {
/**
* reserved for 'contracts'-namespace\
* you need to use the `./contracts/index.ts` file instead
*/
contracts?: "[typesafe-i18n] reserved for 'contracts'-namespace. You need to use the `./contracts/index.ts` file instead."
/**
* reserved for 'customer'-namespace\
* you need to use the `./customer/index.ts` file instead
*/
customer?: "[typesafe-i18n] reserved for 'customer'-namespace. You need to use the `./customer/index.ts` file instead."
}
export type TranslationFunctions = {
/**
* Hi {name}! Please leave a star if you like this project: https://github.com/ivanhofer/typesafe-i18n
*/
greeting: (arg: { name: string }) => LocalizedString
contracts: {
}
customer: {
}
} As you can see the namespaces Is there anything obviously wrong to fix the typing issue? It seems like auto-suggest is also not aware of any content inside the Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It seems that the error is simply that the generator has crashed. And I did not notice it. Sorry. |
Beta Was this translation helpful? Give feedback.
-
That's the error stack trace... probably helpful:
|
Beta Was this translation helpful? Give feedback.
It seems that the error is simply that the generator has crashed. And I did not notice it. Sorry.