vite-pwa / astro

Zero-config PWA Integration for Astro
https://vite-pwa-org.netlify.app/frameworks/astro
MIT License
193 stars 7 forks source link

Feature: i18n manifest.json generation #24

Open jlarmstrongiv opened 1 year ago

jlarmstrongiv commented 1 year ago

I maintain astro-i18n-aut, an internalization (i18n) framework for Astro. Astro itself is preparing to support i18n in core.

It is possible to localize a PWA web manifest, but the current config assumes only one language.

There are issues in other vite-pwa packages describing similar functionality:

It would be wonderful to support i18n in @vite-pwa/astro


In the meantime, would I be able to add it myself if I:

userquin commented 1 year ago

@jlarmstrongiv you can generate the webmanifest using an endpoint (add proper cache headers, dont cache and must-revalidate: max-age with 0 and must-revalidate, check elk.zone for the headers), you will need to add them via runtimeCaching and will not work offline after first visit (the cache will be created on first request and them cached).

Beware, some OS/browser will have long refresh period and not all features in the webmanifest will be updated: https://web.dev/manifest-updates/

You will need to exclude manifest with false and add the logic to add the webmanifest properly.

userquin commented 1 year ago

@jlarmstrongiv you can check elk.zone repo:

jlarmstrongiv commented 1 year ago

Thank you @userquin! That’s extremely helpful.

I really like how your example supports dark mode and is excluded from the service worker cache. Seeing the header examples is helpful too.

userquin commented 1 year ago

@jlarmstrongiv here some pwa hints (user and develop) https://docs.elk.zone/pwa

Can be found in docs folder in elk repo (nuxt docus)