#Hooks Starlight error after update

3 messages · Page 1 of 1 (latest)

fading briarBOT
#

Hi @compact whale. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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 injectTranslations from your plugin’s config:setup hook to the i18n:setup hook.
  • 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
  },
};

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.