astrolicious / i18n

Yet another i18n integration for Astro with server and client utilities, type safety and translations built-in.
https://astro-i18n.netlify.app/
MIT License
48 stars 3 forks source link

Error "Cannot find module 'i18n:astro' or its corresponding type declarations." on a fresh Astro project #32

Closed quasiDigi closed 1 month ago

quasiDigi commented 1 month ago

What I did:

  1. Created a new Astro project through npm, options > ts: strictest, template: blog, install dependencies

    npm create astro@latest
  2. I've added I18n for Astro > options: yes to all

    npm run astro add @astrolicious/i18n
  3. Added routes and locales folders in src, if not dev server through npx astro dev wouldn't launch

  4. On my BlogPost layout I try to get the locale, as explained in the docs:

    
    ---
    import { getLocale } from "i18n:astro"

const locale = getLocale()


### Result:
I get the following error:

Cannot find module 'i18n:astro' or its corresponding type declarations.



best,
q.
florian-lefebvre commented 1 month ago

Hi! It needs to write types to your project, you need to run npm run astro sync. Let me know if that works!

quasiDigi commented 1 month ago

Hi, thanks for the fast reply! I forgot to mention that I did the npx version npx astro sync yesterday. Today, I did npm run astro sync and the error message is still there. Nevertheless, it seems to work, as console.log("locale: ", locale); after the const locale = getLocale(); is outputting the locale.

florian-lefebvre commented 1 month ago

Ah I think I know why. It's most likely an upstream issue, I'll push a fix this afternoon https://github.com/florian-lefebvre/astro-integration-kit/issues/117

florian-lefebvre commented 1 month ago

Fix should be available in 0.5.0 (note it requires Astro >= 4.12.0)