according to https://starlight.astro.build/guides/i18n/#extend-translation-schema
after configuring the extended keys as it said in the doc,
how do I use the texts in my component?
#i18n keys
7 messages · Page 1 of 1 (latest)
Hi @solemn fiber. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To use the translated texts in your component, you can utilize the labels prop provided by Starlight. This prop is an object containing UI strings localized for the current page.
Here is an example of how you might use it:
<Astro.Component labels={labels}>
<h1>{labels['custom.label']}</h1>
</Astro.Component>
In this example, custom.label is the key you added to the translation schema. The labels prop will provide the correct translation for the current locale.
For more information, you can refer to the Starlight documentation on the labels prop (https://starlight.astro.build/reference/overrides/#labels).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@solemn fiber kapa.ai is still learning and improving, please let us know how it did by reacting below
@slim salmon it doesn't work
Let me check the knowledge base for you. One moment! :books:
I'm sorry to hear that you're having trouble. Based on the information provided, it's hard to pinpoint the exact issue. However, here are a few general troubleshooting steps you can take:
-
Check your import statements: Make sure you have imported the necessary components or modules correctly in your
.astrocomponent script or.mdxfile. Check your import path and the name of the imported component. Also, ensure that your imported file contains an extension (e.g.,.astro,.md,.vue,.svelte). Note that file extensions are not required for.js(x)and.ts(x)files only. More details here (https://docs.astro.build/en/guides/troubleshooting/#my-component-is-not-rendering) -
Restart the dev server: If your installation doesn’t seem to be working, try restarting the dev server. If you edit and save a file and don’t see your site update accordingly, try refreshing the page. More details here (https://docs.astro.build/en/guides/integrations-guide/tailwind/#others)
-
Check for common error messages: If you're seeing any error messages in your terminal, you can refer to the Astro troubleshooting guide (https://docs.astro.build/en/guides/troubleshooting/#common-error-messages) for potential solutions.
-
Reach out to the Astro community: If you're still stuck, you can check out the
#supportchannel on Astro's Discord server (https://astro.build/chat). The community there is very helpful and might be able to provide more specific guidance.