-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Hi and thank you for this plugin !
I have an i18n website using @nuxtjs/i18n with a dropdown to switch locale.
It's working fine on my website
Inside my PWA, if I switch the locale manually and navigate through the app, it's working great.
But whenever I close the app, I'm falling back to the default locale.
Here is my nuxt.config.ts
i18n: {
baseUrl: process.env.WEBSITE_URL,
strategy: 'prefix_and_default',
customRoutes: 'config',
trailingSlash: false,
lazy: true,
skipSettingLocaleOnNavigate: false,
debug: false,
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'swany.i18n',
redirectOn: 'root',
},
},
pwa: {
strategies: 'generateSW',
registerType: 'autoUpdate',
devOptions: {
enabled: mode !== 'production',
type: 'module',
navigateFallback: '/',
suppressWarnings: true,
},
workbox: {
navigateFallback: '/',
},
pwaAssets: {
disabled: false,
config: true,
},
manifest: {
lang: 'en',
name: 'name',
short_name: 'name',
description: 'description',
id: '/blog',
start_url: '/blog',
scope: '/',
display: 'standalone',
orientation: 'portrait',
background_color: '#FFF',
theme_color: '#FFF',
prefer_related_applications: true,
},
},
It think it's because start_url is pointing to the default locale, so I will always be opening my PWA using the default locale.
I've seen someone suggesting localized webmanifests generation #52, would be great but once the PWA is installed it will not be possible to switch the locale because start_url is static.
I am thinking about checking at startup if I'm inside the PWA, if yes, redirect to the correct localized route using useI18n().locale.
But :
- I don't know how to check if I'm inside a PWA
- I'm not sure if the
useI18n().localewill be set to the default locale before my check because ofskipSettingLocaleOnNavigate: false
My questions :
- Should I use
$pwa.isPWAInstalledor it is just a flag to know if I have the PWA installed on my device ? - If
useI18n().localeis not correct I will have to persist the user locale manually, how can I do this with a PWA ?