-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(i18n): use i18next-fetch-backend instead of i18next-http-backend
- Loading branch information
Showing
41 changed files
with
209 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { supportedLngs } from '@app-builder/services/i18n/i18n-config'; | ||
import { resources } from '@app-builder/services/i18n/resources/resources.server'; | ||
import { json, type LoaderFunctionArgs } from '@remix-run/node'; | ||
import { cacheHeader } from 'pretty-cache-header'; | ||
import { z } from 'zod'; | ||
|
||
export function loader({ request }: LoaderFunctionArgs) { | ||
const url = new URL(request.url); | ||
|
||
const lng = z.enum(supportedLngs).parse(url.searchParams.get('lng')); | ||
|
||
const namespaces = resources[lng]; | ||
|
||
const ns = z | ||
.string() | ||
.refine((ns): ns is keyof typeof namespaces => { | ||
return Object.keys(resources[lng]).includes(ns); | ||
}) | ||
.parse(url.searchParams.get('ns')); | ||
|
||
const headers = new Headers(); | ||
|
||
// On production, we want to add cache headerlocals to the response | ||
// eslint-disable-next-line no-restricted-properties | ||
if (process.env.NODE_ENV === 'production') { | ||
headers.set( | ||
'Cache-Control', | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call | ||
cacheHeader({ | ||
maxAge: '1d', | ||
staleWhileRevalidate: '7d', | ||
staleIfError: '7d', | ||
}), | ||
); | ||
} | ||
|
||
return json(namespaces[ns], { headers }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,8 @@ | ||
import type api from '../../../public/locales/en/api.json'; | ||
import type auth from '../../../public/locales/en/auth.json'; | ||
import type cases from '../../../public/locales/en/cases.json'; | ||
import type common from '../../../public/locales/en/common.json'; | ||
import type data from '../../../public/locales/en/data.json'; | ||
import type decisions from '../../../public/locales/en/decisions.json'; | ||
import type filters from '../../../public/locales/en/filters.json'; | ||
import type lists from '../../../public/locales/en/lists.json'; | ||
import type navigation from '../../../public/locales/en/navigation.json'; | ||
import type scenarios from '../../../public/locales/en/scenarios.json'; | ||
import type scheduledExecution from '../../../public/locales/en/scheduledExecution.json'; | ||
import type settings from '../../../public/locales/en/settings.json'; | ||
import type transfercheck from '../../../public/locales/en/transfercheck.json'; | ||
import type upload from '../../../public/locales/en/upload.json'; | ||
import type workflows from '../../../public/locales/en/workflows.json'; | ||
import { type defaultNS } from './i18n-config'; | ||
import { type resources } from './resources/resources.server'; | ||
|
||
declare module 'i18next' { | ||
interface CustomTypeOptions { | ||
defaultNS: typeof defaultNS; | ||
resources: { | ||
api: typeof api; | ||
cases: typeof cases; | ||
common: typeof common; | ||
data: typeof data; | ||
decisions: typeof decisions; | ||
filters: typeof filters; | ||
navigation: typeof navigation; | ||
lists: typeof lists; | ||
auth: typeof auth; | ||
scenarios: typeof scenarios; | ||
scheduledExecution: typeof scheduledExecution; | ||
settings: typeof settings; | ||
transfercheck: typeof transfercheck; | ||
upload: typeof upload; | ||
workflows: typeof workflows; | ||
}; | ||
resources: (typeof resources)['en']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/app-builder/src/services/i18n/resources/en.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import api from '@app-builder/locales/en/api.json'; | ||
import auth from '@app-builder/locales/en/auth.json'; | ||
import cases from '@app-builder/locales/en/cases.json'; | ||
import common from '@app-builder/locales/en/common.json'; | ||
import data from '@app-builder/locales/en/data.json'; | ||
import decisions from '@app-builder/locales/en/decisions.json'; | ||
import filters from '@app-builder/locales/en/filters.json'; | ||
import lists from '@app-builder/locales/en/lists.json'; | ||
import navigation from '@app-builder/locales/en/navigation.json'; | ||
import scenarios from '@app-builder/locales/en/scenarios.json'; | ||
import scheduledExecution from '@app-builder/locales/en/scheduledExecution.json'; | ||
import settings from '@app-builder/locales/en/settings.json'; | ||
import transfercheck from '@app-builder/locales/en/transfercheck.json'; | ||
import upload from '@app-builder/locales/en/upload.json'; | ||
import workflows from '@app-builder/locales/en/workflows.json'; | ||
|
||
export const en = { | ||
api, | ||
cases, | ||
common, | ||
data, | ||
decisions, | ||
filters, | ||
navigation, | ||
lists, | ||
auth, | ||
scenarios, | ||
scheduledExecution, | ||
settings, | ||
transfercheck, | ||
upload, | ||
workflows, | ||
}; |
Oops, something went wrong.