mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-24 18:59:17 +00:00
Cachebust languages.json (#34705)
* Cachebust languages.json To avoid loading stale language files. The individual language files as hashbusted but the metadata file is not, and it is not feasible to do so. * Switch cachebust to use Date.now to further avoid collisions * Fix tests * Fix tests
This commit is contained in:
committed by
GitHub
parent
bfd2d16fa6
commit
ceaa3ff74e
@@ -45,7 +45,7 @@ export function setupLanguageMock() {
|
||||
|
||||
fetchMock
|
||||
.get(
|
||||
"end:/i18n/languages.json",
|
||||
"include:/i18n/languages.json?",
|
||||
{
|
||||
en: "en_EN.json",
|
||||
de: "de_DE.json",
|
||||
|
||||
@@ -48,7 +48,7 @@ export function setupLanguageMock() {
|
||||
fetchMock.mockGlobal();
|
||||
fetchMock
|
||||
.get(
|
||||
"end:/i18n/languages.json",
|
||||
"include:/i18n/languages.json?",
|
||||
{
|
||||
en: "en_EN.json",
|
||||
de: "de_DE.json",
|
||||
|
||||
@@ -88,7 +88,7 @@ const config: StorybookConfig = {
|
||||
name: "language-middleware",
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, res, next) => {
|
||||
if (req.url === "/i18n/languages.json") {
|
||||
if (req.url?.split("?")[0] === "/i18n/languages.json") {
|
||||
// Dynamically generate a languages.json file based on what files are available
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.end(JSON.stringify(languages));
|
||||
|
||||
@@ -433,7 +433,8 @@ async function getLanguage(langPath: string): Promise<ICounterpartTranslation> {
|
||||
}
|
||||
|
||||
export async function getLangsJson(): Promise<Languages> {
|
||||
const url = i18nFolder + "languages.json";
|
||||
const cachebust = Date.now();
|
||||
const url = `${i18nFolder}languages.json?${cachebust}`;
|
||||
|
||||
const res = await fetch(url, { method: "GET" });
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ expect.addSnapshotSerializer({
|
||||
|
||||
function setupLanguageMock(): void {
|
||||
fetchMock
|
||||
.get("end:/i18n/languages.json", {
|
||||
.get("include:/i18n/languages.json?", {
|
||||
en: "en_EN.json",
|
||||
})
|
||||
.get("end:en_EN.json", en);
|
||||
|
||||
Reference in New Issue
Block a user