#Hooks Starlight error after update
3 messages · Page 1 of 1 (latest)
The error message:
[@astrojs/starlight] An unhandled error occurred while running the "astro:config:setup" hook
injectTranslations is not a function
suggests that a Starlight plugin is trying to use the injectTranslations function inside the astro:config:setup hook. However, according to the Starlight plugin API, injectTranslations is only available in the i18n:setup hook, not in config:setup Starlight Plugins Reference.
How to fix:
- Move any calls to
injectTranslationsfrom your plugin’sconfig:setuphook to thei18n:setuphook. - The correct usage is:
export default {
name: 'plugin-with-translations',
hooks: {
'i18n:setup'({ injectTranslations }) {
injectTranslations({
en: { 'myPlugin.doThing': 'Do the thing' },
fr: { 'myPlugin.doThing': 'Faire le truc' },
});
},
// ...other hooks
},
};
- In the
config:setuphook, you can useuseTranslationsto access translations, but not inject them Starlight Plugins Reference.
Summary:
Update your plugin(s) so that injectTranslations is only called in the i18n:setup hook, not in config:setup. This should resolve the error after upgrading Starlight and Astro.
If you continue to have issues, check that all your plugins and Starlight itself are updated to the latest versions, as breaking changes may have occurred in recent releases Updating Starlight.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@compact whale Kapa.ai is still learning and improving, please let me know how I did by reacting below.