feat: add Latvian (lv) locale support
This commit is contained in:
@@ -10,6 +10,7 @@ import koMessages from '@/locales/ko/common.json';
|
|||||||
import esMessages from '@/locales/es/common.json';
|
import esMessages from '@/locales/es/common.json';
|
||||||
import itMessages from '@/locales/it/common.json';
|
import itMessages from '@/locales/it/common.json';
|
||||||
import deMessages from '@/locales/de/common.json';
|
import deMessages from '@/locales/de/common.json';
|
||||||
|
import lvMessages from '@/locales/lv/common.json';
|
||||||
import nlMessages from '@/locales/nl/common.json';
|
import nlMessages from '@/locales/nl/common.json';
|
||||||
import plMessages from '@/locales/pl/common.json';
|
import plMessages from '@/locales/pl/common.json';
|
||||||
import ptMessages from '@/locales/pt/common.json';
|
import ptMessages from '@/locales/pt/common.json';
|
||||||
@@ -25,6 +26,7 @@ const ALL_MESSAGES = {
|
|||||||
es: esMessages,
|
es: esMessages,
|
||||||
it: itMessages,
|
it: itMessages,
|
||||||
de: deMessages,
|
de: deMessages,
|
||||||
|
lv: lvMessages,
|
||||||
nl: nlMessages,
|
nl: nlMessages,
|
||||||
pl: plMessages,
|
pl: plMessages,
|
||||||
pt: ptMessages,
|
pt: ptMessages,
|
||||||
|
|||||||
@@ -4,16 +4,32 @@ import { useEffect } from "react";
|
|||||||
|
|
||||||
export function ServiceWorkerRegistration() {
|
export function ServiceWorkerRegistration() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window !== "undefined" && "serviceWorker" in navigator) {
|
if (typeof window === "undefined" || !("serviceWorker" in navigator)) {
|
||||||
navigator.serviceWorker
|
return;
|
||||||
.register("/sw.js")
|
|
||||||
.then((registration) => {
|
|
||||||
console.log("Service Worker registered successfully:", registration);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error("Service Worker registration failed:", error);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== "production") {
|
||||||
|
// In development, unregister any previously installed service worker
|
||||||
|
// and clear its caches so hot reload always serves fresh assets.
|
||||||
|
navigator.serviceWorker.getRegistrations().then((registrations) => {
|
||||||
|
registrations.forEach((registration) => registration.unregister());
|
||||||
|
});
|
||||||
|
if ("caches" in window) {
|
||||||
|
caches.keys().then((keys) => {
|
||||||
|
keys.forEach((key) => caches.delete(key));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
navigator.serviceWorker
|
||||||
|
.register("/sw.js")
|
||||||
|
.then((registration) => {
|
||||||
|
console.log("Service Worker registered successfully:", registration);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Service Worker registration failed:", error);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export function LanguageSwitcher({ className }: { className?: string }) {
|
|||||||
{ value: 'es', label: 'Español' },
|
{ value: 'es', label: 'Español' },
|
||||||
{ value: 'it', label: 'Italiano' },
|
{ value: 'it', label: 'Italiano' },
|
||||||
{ value: 'de', label: 'Deutsch' },
|
{ value: 'de', label: 'Deutsch' },
|
||||||
|
{ value: 'lv', label: 'Latviešu' },
|
||||||
{ value: 'nl', label: 'Nederlands' },
|
{ value: 'nl', label: 'Nederlands' },
|
||||||
{ value: 'pl', label: 'Polski' },
|
{ value: 'pl', label: 'Polski' },
|
||||||
{ value: 'pt', label: 'Português' },
|
{ value: 'pt', label: 'Português' },
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ export default getRequestConfig(async ({ requestLocale }) => {
|
|||||||
case 'ko':
|
case 'ko':
|
||||||
messages = (await import('../locales/ko/common.json')).default;
|
messages = (await import('../locales/ko/common.json')).default;
|
||||||
break;
|
break;
|
||||||
|
case 'lv':
|
||||||
|
messages = (await import('../locales/lv/common.json')).default;
|
||||||
|
break;
|
||||||
case 'nl':
|
case 'nl':
|
||||||
messages = (await import('../locales/nl/common.json')).default;
|
messages = (await import('../locales/nl/common.json')).default;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import { defineRouting } from 'next-intl/routing';
|
import { defineRouting } from 'next-intl/routing';
|
||||||
|
|
||||||
export const routing = defineRouting({
|
export const routing = defineRouting({
|
||||||
locales: ['en', 'fr', 'de', 'es', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'zh'],
|
locales: ['en', 'fr', 'de', 'es', 'it', 'ja', 'ko', 'lv', 'nl', 'pl', 'pt', 'ru', 'zh'],
|
||||||
defaultLocale: 'en',
|
defaultLocale: 'en',
|
||||||
localePrefix: 'never'
|
localePrefix: 'never'
|
||||||
});
|
});
|
||||||
|
|||||||
+16
-52
@@ -1,62 +1,26 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
|
|
||||||
const CACHE_NAME = "bulwark-v1";
|
// Self-destructing service worker.
|
||||||
const STATIC_ASSETS = ["/", "/manifest.json"];
|
//
|
||||||
|
// The previous version of this file used a cache-first strategy with no
|
||||||
|
// dev-mode guard, which pinned stale JS/HTML chunks until a hard reload.
|
||||||
|
// This replacement unregisters itself and wipes all caches as soon as the
|
||||||
|
// browser picks it up. Browsers re-fetch sw.js on every navigation to check
|
||||||
|
// for updates, so any client running the old worker will swap to this one
|
||||||
|
// on their next page load and then lose the worker entirely.
|
||||||
|
|
||||||
self.addEventListener("install", (event) => {
|
self.addEventListener("install", () => {
|
||||||
event.waitUntil(
|
|
||||||
caches.open(CACHE_NAME).then((cache) => {
|
|
||||||
return cache.addAll(STATIC_ASSETS);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
self.skipWaiting();
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("activate", (event) => {
|
self.addEventListener("activate", (event) => {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.keys().then((cacheNames) => {
|
(async () => {
|
||||||
return Promise.all(
|
const cacheNames = await caches.keys();
|
||||||
cacheNames
|
await Promise.all(cacheNames.map((name) => caches.delete(name)));
|
||||||
.filter((cacheName) => cacheName !== CACHE_NAME)
|
await self.registration.unregister();
|
||||||
.map((cacheName) => caches.delete(cacheName))
|
const clients = await self.clients.matchAll({ type: "window" });
|
||||||
);
|
clients.forEach((client) => client.navigate(client.url));
|
||||||
})
|
})()
|
||||||
);
|
|
||||||
self.clients.claim();
|
|
||||||
});
|
|
||||||
|
|
||||||
self.addEventListener("fetch", (event) => {
|
|
||||||
// Skip non-GET requests
|
|
||||||
if (event.request.method !== "GET") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip API requests and external requests
|
|
||||||
if (
|
|
||||||
event.request.url.includes("/api/") ||
|
|
||||||
!event.request.url.startsWith(self.location.origin)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.respondWith(
|
|
||||||
caches.match(event.request).then((response) => {
|
|
||||||
if (response) {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fetch(event.request).then((response) => {
|
|
||||||
if (!response || response.status !== 200 || response.type === "error") {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
const responseToCache = response.clone();
|
|
||||||
caches.open(CACHE_NAME).then((cache) => {
|
|
||||||
cache.put(event.request, responseToCache);
|
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user