Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client rendered translation parent empty object (SvelteKit - Node) #752

Open
leo-mangold opened this issue Dec 2, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@leo-mangold
Copy link

Version

5.26.2

Describe the bug

I'm creating a form and I have a custom field component which shows descriptions, titles and more. I pass an object of translations to that component containing the translations: <Field lang={$LL.form.fields.duration_type} ... />. From within the component I access the strings with {lang?.label?.()}. This work perfectly fine when running the development server

Now the problem:
When I build the project (with node adapter) and open the page the translations are gone. On further inspection one can see (when refreshing the page) that the right translation is visible for a short period of time and then vanishes. This means that the server rendered page contained the translations but the client render pass removed them.
But using translations in any other way works completely fine: {$LL.form.fields.duration_type.label()}

So the problem is that the lang object becomes empty on the client, since when I log the object, or display it, it is empty.

Reproduction

// Field.svelte
<script context="module" lang="ts">
	interface LangType {
		label?: () => string;
		description?: () => string;
		info?: () => string;
		options?: { [key: string]: () => string };
	}
</script>

<script lang="ts" generics="T extends LangType">
        ...
	export let lang: T = {} as T;

</script>

...

    <h3 class="text-lg font-semibold">
        {lang?.label?.()}
    </h3>
    
    {#if lang?.description}
	    <p class="text-sm text-muted-foreground">{lang?.description()}</p>
    {/if}
...
// Form.svelte
{$LL.form.fields.duration_type.label()} // this works
<Field lang={$LL.form.fields.duration_type} /> // this doesn't

### Logs

_No response_

### Config

```JSON
{
	"adapter": "svelte",
	"esmImports": true,
	"outputPath": "./src/lib/i18n",
	"$schema": "https://unpkg.com/[email protected]/schema/typesafe-i18n.json"
}

Additional information

No response

@leo-mangold leo-mangold added the bug Something isn't working label Dec 2, 2023
@ALYREZA
Copy link

ALYREZA commented Jul 20, 2024

same bug in expo 51 with latest package update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants