Replies: 10 comments 8 replies
-
Kind of related feature that might be interesting. In a very large project, having all of the copy in one place becomes challenging. Right now (I could be wrong) the setup forces a structure like:
whereas something like this, allowing the copy to be colocated with the component/function could be very helpful to avoid jumping around in the codebase:
|
Beta Was this translation helpful? Give feedback.
-
I'm not sure if I got it correct. You can do that already, but you would need to import these objects inside the You can have a file export const notifications_en = {
prop1: 'This is a test'
}
export const notifications_de = {
prop1: 'Das ist ein test'
} and then reference it inside import { notifications_en } from 'src/notifications/published.ts'
const en: BaseTranslation = {
...notifications_en
}
export default en and inside import { notifications_de } from 'src/notifications/published.ts'
const de: Translation = {
...notifications_de
}
export default de Is this what you want? |
Beta Was this translation helpful? Give feedback.
-
@mullwaden did you see my comment above? |
Beta Was this translation helpful? Give feedback.
-
yes! I ended up putting everything in the translations folder though. It works better with the automatic updates of the types. One idea would be to go the route that jest, storybook and less go, where they automatically pick up files, e.g. Imagine then you could do something like
It can be done, but it would require some interesting webpack shenanigans... In fact you could probably at that point entirely hide the types file and make it part of the regular build process. |
Beta Was this translation helpful? Give feedback.
-
@mullwaden sounds interesting. Pleas open a |
Beta Was this translation helpful? Give feedback.
-
@mullwaden I'm interested in this thread, is the discussion available somewhere? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
@mullwaden @EstebanBorai namespaces are here!! 🎉 |
Beta Was this translation helpful? Give feedback.
-
Yea, I thought that then making it global is better somehow. But as you told, keeping it more structured make it more useful. Спасибо @ivanhofer |
Beta Was this translation helpful? Give feedback.
-
There is a simple slug problem with - and — on namespace: why-us.svelte is not addable to namespace.
errs:
There is also a page with path: src\routes[lang]\analysis[title].svelte import type { BaseTranslation } from '../../i18n-types' const en_analysis_[title]: BaseTranslation = { Not works as en_analysis_[title]. How should we proceed please? Need help @ivanhofer
const loadNamespaceAsync = async (locale, namespace) => void updateDictionary(locale, { [namespace]: (await localeNamespaceLoaders[locale]namespace).default });
TypeError: localeNamespaceLoaders[locale][namespace] is not a function |
Beta Was this translation helpful? Give feedback.
-
Thanks @ivanhofer . Understood now. en_analysis_[title] can't be used, but we can use any namespace independent from pathnames |
Beta Was this translation helpful? Give feedback.
-
Namespaces would be a native option to load only selected parts of the translations. Useful for bigger applications so not all messages need to load the same time e.g. translation that are only needed in the settings panel are not needed on the login page.
You would define your translations something like:
where
workspace
would be a function that loads the workspace via an async importBecause workspaces would be loaded asynchronously, we would make sure that calling
LL.login.label_password()
would return the translated value: How can we do that?loadWorkspace('login')
functionthe function would need to get called before the actual translation call
since the whole translation object is reactive, we can initialize the loading and as soon as the translations are back, we can update the object that holds all workspaces
A developer then can decide if he manually loads the correct workspace somewhere in the code (e.g. triggered by a certain route) or the user should see blanks until translations are loaded. Also a method to check if a workspace is currently loading will be exposed so a loading spinner can be shown.
It should be possible to nest workspaces as often an user wants.
What needs to be done:
Beta Was this translation helpful? Give feedback.
All reactions