@enonic/nextjs-adapter 3.0.0-RC2 → 3.0.0-RC4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/getClientHydratedHtml.d.ts +2 -0
- package/client/getClientHydratedHtml.jsx +9 -0
- package/client/getClientHydratedHtml.jsx.map +1 -0
- package/common/UrlProcessor.js +3 -3
- package/common/UrlProcessor.js.map +1 -1
- package/common/constants.d.ts +1 -1
- package/common/constants.js +1 -2
- package/common/constants.js.map +1 -1
- package/guillotine/fetchContent.js +5 -5
- package/guillotine/fetchContent.js.map +1 -1
- package/guillotine/fetchContentData.d.ts +2 -2
- package/guillotine/fetchContentData.js +2 -2
- package/guillotine/fetchContentData.js.map +1 -1
- package/guillotine/fetchContentPathsForAllLocales.js +2 -2
- package/guillotine/fetchContentPathsForAllLocales.js.map +1 -1
- package/guillotine/fetchContentPathsForLocale.d.ts +2 -2
- package/guillotine/fetchContentPathsForLocale.js.map +1 -1
- package/guillotine/fetchFromApi.d.ts +2 -2
- package/guillotine/fetchFromApi.js +4 -4
- package/guillotine/fetchFromApi.js.map +1 -1
- package/guillotine/fetchGuillotine.d.ts +2 -2
- package/guillotine/fetchGuillotine.js +2 -2
- package/guillotine/fetchGuillotine.js.map +1 -1
- package/guillotine/fetchMetaData.d.ts +2 -2
- package/guillotine/fetchMetaData.js +2 -2
- package/guillotine/fetchMetaData.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +14 -11
- package/server/getServerRenderedHtml.d.ts +2 -0
- package/server/getServerRenderedHtml.js +4 -0
- package/server/getServerRenderedHtml.js.map +1 -0
- package/src/common/UrlProcessor.ts +3 -3
- package/src/common/constants.ts +1 -2
- package/src/guillotine/fetchContent.ts +5 -5
- package/src/guillotine/fetchContentData.ts +3 -3
- package/src/guillotine/fetchContentPathsForAllLocales.ts +3 -3
- package/src/guillotine/fetchContentPathsForLocale.ts +2 -2
- package/src/guillotine/fetchFromApi.ts +5 -5
- package/src/guillotine/fetchGuillotine.ts +3 -3
- package/src/guillotine/fetchMetaData.ts +3 -3
- package/src/index.ts +3 -3
- package/src/types/index.ts +2 -2
- package/src/utils/getAllLocales.ts +6 -0
- package/src/utils/getContentApiUrl.ts +3 -3
- package/src/utils/getLocaleMapping.ts +24 -0
- package/src/utils/getLocaleMappingByLocale.ts +19 -0
- package/src/utils/getLocaleMappingByProjectId.ts +21 -0
- package/src/utils/{getProjectLocaleConfigs.ts → getLocaleMappings.ts} +2 -2
- package/src/utils/getRequestLocaleInfo.ts +5 -5
- package/types/index.d.ts +2 -2
- package/utils/getAllLocales.d.ts +1 -0
- package/utils/getAllLocales.js +5 -0
- package/utils/getAllLocales.js.map +1 -0
- package/utils/getContentApiUrl.js +2 -2
- package/utils/getContentApiUrl.js.map +1 -1
- package/utils/getLocaleMapping.d.ts +2 -0
- package/utils/{getProjectLocaleConfig.js → getLocaleMapping.js} +6 -6
- package/utils/getLocaleMapping.js.map +1 -0
- package/utils/getLocaleMappingByLocale.d.ts +2 -0
- package/utils/getLocaleMappingByLocale.js +13 -0
- package/utils/getLocaleMappingByLocale.js.map +1 -0
- package/utils/getLocaleMappingByProjectId.d.ts +2 -0
- package/utils/getLocaleMappingByProjectId.js +16 -0
- package/utils/getLocaleMappingByProjectId.js.map +1 -0
- package/utils/getLocaleMappings.d.ts +2 -0
- package/utils/{getProjectLocaleConfigs.js → getLocaleMappings.js} +2 -2
- package/utils/getLocaleMappings.js.map +1 -0
- package/utils/getRequestLocaleInfo.js +4 -4
- package/utils/getRequestLocaleInfo.js.map +1 -1
- package/src/utils/getProjectLocaleConfig.ts +0 -24
- package/src/utils/getProjectLocaleConfigById.ts +0 -21
- package/src/utils/getProjectLocaleConfigByLocale.ts +0 -19
- package/src/utils/getProjectLocales.ts +0 -6
- package/utils/getProjectLocaleConfig.d.ts +0 -2
- package/utils/getProjectLocaleConfig.js.map +0 -1
- package/utils/getProjectLocaleConfigById.d.ts +0 -2
- package/utils/getProjectLocaleConfigById.js +0 -16
- package/utils/getProjectLocaleConfigById.js.map +0 -1
- package/utils/getProjectLocaleConfigByLocale.d.ts +0 -2
- package/utils/getProjectLocaleConfigByLocale.js +0 -13
- package/utils/getProjectLocaleConfigByLocale.js.map +0 -1
- package/utils/getProjectLocaleConfigs.d.ts +0 -2
- package/utils/getProjectLocaleConfigs.js.map +0 -1
- package/utils/getProjectLocales.d.ts +0 -1
- package/utils/getProjectLocales.js +0 -5
- package/utils/getProjectLocales.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {ContentPathItem} from '../types';
|
|
2
2
|
|
|
3
3
|
import {GET_STATIC_PATHS_QUERY} from '../common/constants';
|
|
4
|
-
import {
|
|
4
|
+
import {getLocaleMappings} from '../utils/getLocaleMappings';
|
|
5
5
|
import {fetchContentPathsForLocale} from './fetchContentPathsForLocale';
|
|
6
6
|
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ export async function fetchContentPathsForAllLocales(
|
|
|
10
10
|
query: string = GET_STATIC_PATHS_QUERY,
|
|
11
11
|
countPerLocale = 999,
|
|
12
12
|
): Promise<ContentPathItem[]> {
|
|
13
|
-
const promises = Object.values(
|
|
13
|
+
const promises = Object.values(getLocaleMappings()).map(
|
|
14
14
|
config => fetchContentPathsForLocale(
|
|
15
15
|
path, config, query, countPerLocale,
|
|
16
16
|
),
|
|
@@ -18,4 +18,4 @@ export async function fetchContentPathsForAllLocales(
|
|
|
18
18
|
return Promise.all(promises).then(results => {
|
|
19
19
|
return results.reduce((all, localePaths) => all.concat(localePaths), []);
|
|
20
20
|
});
|
|
21
|
-
}
|
|
21
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {ContentApiBaseBody, ContentPathItem, GuillotineResult,
|
|
1
|
+
import type {ContentApiBaseBody, ContentPathItem, GuillotineResult, LocaleMapping} from '../types';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import {GET_STATIC_PATHS_QUERY} from '../common/constants';
|
|
@@ -8,7 +8,7 @@ import {fetchGuillotine} from './fetchGuillotine';
|
|
|
8
8
|
|
|
9
9
|
export async function fetchContentPathsForLocale(
|
|
10
10
|
path: string,
|
|
11
|
-
config:
|
|
11
|
+
config: LocaleMapping,
|
|
12
12
|
query: string = GET_STATIC_PATHS_QUERY,
|
|
13
13
|
count = 999,
|
|
14
14
|
): Promise<ContentPathItem[]> {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {FetchOptions, GuillotineResponse, GuillotineResponseJson,
|
|
1
|
+
import type {FetchOptions, GuillotineResponse, GuillotineResponseJson, LocaleMapping} from '../types';
|
|
2
2
|
|
|
3
3
|
/** Generic fetch */
|
|
4
4
|
export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
5
5
|
apiUrl: string,
|
|
6
|
-
|
|
6
|
+
mapping: LocaleMapping,
|
|
7
7
|
options?: FetchOptions,
|
|
8
8
|
): Promise<GuillotineResponseJson> {
|
|
9
9
|
|
|
10
10
|
const opts = {
|
|
11
11
|
method: options?.method || 'POST',
|
|
12
12
|
body: options?.body ? JSON.stringify(options?.body) : null,
|
|
13
|
-
headers: mergeHeaders(
|
|
13
|
+
headers: mergeHeaders(mapping, options?.headers),
|
|
14
14
|
next: options?.next,
|
|
15
15
|
cache: options?.cache,
|
|
16
16
|
};
|
|
@@ -60,7 +60,7 @@ export async function fetchFromApi<Data = Record<string, unknown>>(
|
|
|
60
60
|
return json;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
function mergeHeaders(
|
|
63
|
+
function mergeHeaders(mapping: LocaleMapping, headers?: HeadersInit): Headers {
|
|
64
64
|
const newHeaders = new Headers({
|
|
65
65
|
'Accept': 'application/json',
|
|
66
66
|
'Content-Type': 'application/json',
|
|
@@ -71,6 +71,6 @@ function mergeHeaders(projectConfig: ProjectLocaleConfig, headers?: HeadersInit)
|
|
|
71
71
|
}
|
|
72
72
|
// append last to make sure it is not overwritten
|
|
73
73
|
}
|
|
74
|
-
newHeaders.set('X-Guillotine-SiteKey',
|
|
74
|
+
newHeaders.set('X-Guillotine-SiteKey', mapping.site);
|
|
75
75
|
return newHeaders;
|
|
76
76
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {FetchOptions, GuillotineResult,
|
|
1
|
+
import type {FetchOptions, GuillotineResult, LocaleMapping} from '../types';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import {fetchFromApi} from './fetchFromApi';
|
|
@@ -7,7 +7,7 @@ import {fetchFromApi} from './fetchFromApi';
|
|
|
7
7
|
/** Guillotine-specialized fetch, using the generic fetch above */
|
|
8
8
|
export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
9
9
|
contentApiUrl: string,
|
|
10
|
-
|
|
10
|
+
mapping: LocaleMapping,
|
|
11
11
|
options?: FetchOptions,
|
|
12
12
|
): Promise<GuillotineResult> {
|
|
13
13
|
const body = options?.body;
|
|
@@ -24,7 +24,7 @@ export async function fetchGuillotine<Data = Record<string, unknown>>(
|
|
|
24
24
|
const pathMessage = path ? JSON.stringify(path) : '';
|
|
25
25
|
return await fetchFromApi<Data>(
|
|
26
26
|
contentApiUrl,
|
|
27
|
-
|
|
27
|
+
mapping,
|
|
28
28
|
options,
|
|
29
29
|
)
|
|
30
30
|
.then(json => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {ContentApiBaseBody, MetaResult,
|
|
1
|
+
import type {ContentApiBaseBody, MetaResult, LocaleMapping} from '../types';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import {getMetaQuery, pageFragmentQuery} from './getMetaData';
|
|
@@ -8,7 +8,7 @@ import {fetchGuillotine} from './fetchGuillotine';
|
|
|
8
8
|
export const fetchMetaData = async (
|
|
9
9
|
contentApiUrl: string,
|
|
10
10
|
xpContentPath: string,
|
|
11
|
-
|
|
11
|
+
mapping: LocaleMapping,
|
|
12
12
|
headers?: {},
|
|
13
13
|
): Promise<MetaResult> => {
|
|
14
14
|
const body: ContentApiBaseBody = {
|
|
@@ -17,7 +17,7 @@ export const fetchMetaData = async (
|
|
|
17
17
|
path: xpContentPath,
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
|
-
const metaResult = await fetchGuillotine<MetaResult>(contentApiUrl,
|
|
20
|
+
const metaResult = await fetchGuillotine<MetaResult>(contentApiUrl, mapping, {
|
|
21
21
|
body,
|
|
22
22
|
headers,
|
|
23
23
|
});
|
package/src/index.ts
CHANGED
|
@@ -29,9 +29,9 @@ export {validateData} from './guillotine/validateData';
|
|
|
29
29
|
export {I18n} from './i18n/i18n';
|
|
30
30
|
|
|
31
31
|
export {getContentApiUrl} from './utils/getContentApiUrl';
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
32
|
+
export {getLocaleMapping} from './utils/getLocaleMapping';
|
|
33
|
+
export {getLocaleMappingByProjectId} from './utils/getLocaleMappingByProjectId';
|
|
34
|
+
export {getLocaleMappingByLocale} from './utils/getLocaleMappingByLocale';
|
|
35
35
|
export {getRequestLocaleInfo} from './utils/getRequestLocaleInfo';
|
|
36
36
|
export {sanitizeGraphqlName} from './utils/sanitizeGraphqlName';
|
|
37
37
|
|
package/src/types/index.ts
CHANGED
|
@@ -33,14 +33,14 @@ export interface PreviewParams {
|
|
|
33
33
|
params: Record<string, string>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface
|
|
36
|
+
export interface LocaleMapping {
|
|
37
37
|
default: boolean
|
|
38
38
|
project: string
|
|
39
39
|
site: string
|
|
40
40
|
locale: string
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export type
|
|
43
|
+
export type LocaleMappings = Record<string, LocaleMapping>;
|
|
44
44
|
|
|
45
45
|
export type SelectorName = 'contentType' | 'page' | 'component' | 'part' | 'layout' | 'macro';
|
|
46
46
|
|
|
@@ -3,13 +3,13 @@ import type {Context} from '../types';
|
|
|
3
3
|
|
|
4
4
|
import {RENDER_MODE} from '../common/constants';
|
|
5
5
|
import {API_URL} from '../common/env';
|
|
6
|
-
import {
|
|
6
|
+
import {getLocaleMapping} from './getLocaleMapping';
|
|
7
7
|
import {fixDoubleSlashes} from './fixDoubleSlashes';
|
|
8
8
|
import {getRenderMode} from './getRenderMode';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export function getContentApiUrl(context: Context): string {
|
|
12
|
-
const project =
|
|
12
|
+
const project = getLocaleMapping(context).project;
|
|
13
13
|
const branch = getRenderMode(context) === RENDER_MODE.NEXT
|
|
14
14
|
? 'master'
|
|
15
15
|
: getRenderMode(context) === RENDER_MODE.LIVE
|
|
@@ -17,4 +17,4 @@ export function getContentApiUrl(context: Context): string {
|
|
|
17
17
|
: 'draft';
|
|
18
18
|
|
|
19
19
|
return fixDoubleSlashes(`${API_URL}/${project}/${branch}`);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type {Context, LocaleMapping} from '../types';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import {PROJECT_ID_HEADER} from '../common/constants';
|
|
5
|
+
import {getLocaleMappingByProjectId} from './getLocaleMappingByProjectId';
|
|
6
|
+
import {getLocaleMappingByLocale} from './getLocaleMappingByLocale';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function getLocaleMapping(context: Context): LocaleMapping {
|
|
10
|
+
const projectId = context.headers?.get(PROJECT_ID_HEADER);
|
|
11
|
+
|
|
12
|
+
let config: LocaleMapping;
|
|
13
|
+
if (projectId) {
|
|
14
|
+
// first use project id header
|
|
15
|
+
config = getLocaleMappingByProjectId(projectId, false);
|
|
16
|
+
}
|
|
17
|
+
if (!config) {
|
|
18
|
+
// next try to use locale from url
|
|
19
|
+
// it will fall back to default locale if not found
|
|
20
|
+
config = getLocaleMappingByLocale(context.locale);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type {LocaleMapping} from '../types';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import {getLocaleMappings} from './getLocaleMappings';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export function getLocaleMappingByLocale(locale?: string, useDefault = true): LocaleMapping {
|
|
8
|
+
const mappings = getLocaleMappings();
|
|
9
|
+
|
|
10
|
+
let config: LocaleMapping;
|
|
11
|
+
if (locale) {
|
|
12
|
+
config = mappings[locale];
|
|
13
|
+
}
|
|
14
|
+
if (!config && useDefault) {
|
|
15
|
+
config = Object.values(mappings).find(c => c.default);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {LocaleMapping} from '../types';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import {getLocaleMappings} from './getLocaleMappings';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export function getLocaleMappingByProjectId(projectId?: string, useDefault = true): LocaleMapping {
|
|
8
|
+
const mappings = getLocaleMappings();
|
|
9
|
+
|
|
10
|
+
let config: LocaleMapping;
|
|
11
|
+
if (projectId) {
|
|
12
|
+
config = Object.values(mappings).find(p => {
|
|
13
|
+
return p?.project?.toLowerCase() === projectId.toLowerCase();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (!config && useDefault) {
|
|
17
|
+
config = Object.values(mappings).find(c => c.default);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {LocaleMappings} from '../types';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import {ENV_VARS} from '../common/constants';
|
|
@@ -9,7 +9,7 @@ import {MAPPINGS} from '../common/env';
|
|
|
9
9
|
const PROJECT_CONFIG_REGEXP = /^([\w-]+):([^/\s]+)(\/[\w.-]+)?$/i;
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
export function
|
|
12
|
+
export function getLocaleMappings(): LocaleMappings {
|
|
13
13
|
const str = MAPPINGS;
|
|
14
14
|
if (!str?.length) {
|
|
15
15
|
throw new Error(`Did you forget to define "${ENV_VARS.MAPPINGS}" environmental variable?
|
|
@@ -4,18 +4,18 @@ import type {Context} from '../types';
|
|
|
4
4
|
import Negotiator from 'negotiator';
|
|
5
5
|
import {match as localeMatcher} from '@formatjs/intl-localematcher';
|
|
6
6
|
import {PROJECT_ID_HEADER} from '../common/constants';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import {getLocaleMappings} from './getLocaleMappings';
|
|
8
|
+
import {getLocaleMappingByProjectId} from './getLocaleMappingByProjectId';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export function getRequestLocaleInfo(context: Context) {
|
|
12
12
|
let locale: string;
|
|
13
|
-
const configs =
|
|
13
|
+
const configs = getLocaleMappings();
|
|
14
14
|
const locales = Object.keys(configs);
|
|
15
15
|
const defaultLocale = locales.find((locale) => configs[locale].default);
|
|
16
16
|
const projectId = context.headers?.get(PROJECT_ID_HEADER);
|
|
17
17
|
if (projectId) {
|
|
18
|
-
locale =
|
|
18
|
+
locale = getLocaleMappingByProjectId(projectId, false)?.locale;
|
|
19
19
|
|
|
20
20
|
} else {
|
|
21
21
|
locale = context.locale;
|
|
@@ -26,4 +26,4 @@ export function getRequestLocaleInfo(context: Context) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
return {locale, locales, defaultLocale};
|
|
29
|
-
}
|
|
29
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -25,13 +25,13 @@ export interface PreviewParams {
|
|
|
25
25
|
headers: Record<string, string>;
|
|
26
26
|
params: Record<string, string>;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
28
|
+
export interface LocaleMapping {
|
|
29
29
|
default: boolean;
|
|
30
30
|
project: string;
|
|
31
31
|
site: string;
|
|
32
32
|
locale: string;
|
|
33
33
|
}
|
|
34
|
-
export type
|
|
34
|
+
export type LocaleMappings = Record<string, LocaleMapping>;
|
|
35
35
|
export type SelectorName = 'contentType' | 'page' | 'component' | 'part' | 'layout' | 'macro';
|
|
36
36
|
export type FetchOptions = Omit<RequestInit, 'body'> & {
|
|
37
37
|
body?: ContentApiBaseBody;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAllLocales(): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllLocales.js","sourceRoot":"","sources":["../src/utils/getAllLocales.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,MAAM,UAAU,aAAa;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RENDER_MODE } from '../common/constants';
|
|
2
2
|
import { API_URL } from '../common/env';
|
|
3
|
-
import {
|
|
3
|
+
import { getLocaleMapping } from './getLocaleMapping';
|
|
4
4
|
import { fixDoubleSlashes } from './fixDoubleSlashes';
|
|
5
5
|
import { getRenderMode } from './getRenderMode';
|
|
6
6
|
export function getContentApiUrl(context) {
|
|
7
|
-
const project =
|
|
7
|
+
const project = getLocaleMapping(context).project;
|
|
8
8
|
const branch = getRenderMode(context) === RENDER_MODE.NEXT
|
|
9
9
|
? 'master'
|
|
10
10
|
: getRenderMode(context) === RENDER_MODE.LIVE
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContentApiUrl.js","sourceRoot":"","sources":["../src/utils/getContentApiUrl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"getContentApiUrl.js","sourceRoot":"","sources":["../src/utils/getContentApiUrl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC7C,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;IAClD,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,IAAI;QACtD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,IAAI;YACzC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,OAAO,CAAC;IAElB,OAAO,gBAAgB,CAAC,GAAG,OAAO,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { PROJECT_ID_HEADER } from '../common/constants';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export function
|
|
2
|
+
import { getLocaleMappingByProjectId } from './getLocaleMappingByProjectId';
|
|
3
|
+
import { getLocaleMappingByLocale } from './getLocaleMappingByLocale';
|
|
4
|
+
export function getLocaleMapping(context) {
|
|
5
5
|
var _a;
|
|
6
6
|
const projectId = (_a = context.headers) === null || _a === void 0 ? void 0 : _a.get(PROJECT_ID_HEADER);
|
|
7
7
|
let config;
|
|
8
8
|
if (projectId) {
|
|
9
9
|
// first use project id header
|
|
10
|
-
config =
|
|
10
|
+
config = getLocaleMappingByProjectId(projectId, false);
|
|
11
11
|
}
|
|
12
12
|
if (!config) {
|
|
13
13
|
// next try to use locale from url
|
|
14
14
|
// it will fall back to default locale if not found
|
|
15
|
-
config =
|
|
15
|
+
config = getLocaleMappingByLocale(context.locale);
|
|
16
16
|
}
|
|
17
17
|
return config;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=getLocaleMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocaleMapping.js","sourceRoot":"","sources":["../src/utils/getLocaleMapping.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAGpE,MAAM,UAAU,gBAAgB,CAAC,OAAgB;;IAC7C,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAE1D,IAAI,MAAqB,CAAC;IAC1B,IAAI,SAAS,EAAE,CAAC;QACZ,8BAA8B;QAC9B,MAAM,GAAG,2BAA2B,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,kCAAkC;QAClC,mDAAmD;QACnD,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getLocaleMappings } from './getLocaleMappings';
|
|
2
|
+
export function getLocaleMappingByLocale(locale, useDefault = true) {
|
|
3
|
+
const mappings = getLocaleMappings();
|
|
4
|
+
let config;
|
|
5
|
+
if (locale) {
|
|
6
|
+
config = mappings[locale];
|
|
7
|
+
}
|
|
8
|
+
if (!config && useDefault) {
|
|
9
|
+
config = Object.values(mappings).find(c => c.default);
|
|
10
|
+
}
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getLocaleMappingByLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocaleMappingByLocale.js","sourceRoot":"","sources":["../src/utils/getLocaleMappingByLocale.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,MAAM,UAAU,wBAAwB,CAAC,MAAe,EAAE,UAAU,GAAG,IAAI;IACvE,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,IAAI,MAAqB,CAAC;IAC1B,IAAI,MAAM,EAAE,CAAC;QACT,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getLocaleMappings } from './getLocaleMappings';
|
|
2
|
+
export function getLocaleMappingByProjectId(projectId, useDefault = true) {
|
|
3
|
+
const mappings = getLocaleMappings();
|
|
4
|
+
let config;
|
|
5
|
+
if (projectId) {
|
|
6
|
+
config = Object.values(mappings).find(p => {
|
|
7
|
+
var _a;
|
|
8
|
+
return ((_a = p === null || p === void 0 ? void 0 : p.project) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === projectId.toLowerCase();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!config && useDefault) {
|
|
12
|
+
config = Object.values(mappings).find(c => c.default);
|
|
13
|
+
}
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getLocaleMappingByProjectId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocaleMappingByProjectId.js","sourceRoot":"","sources":["../src/utils/getLocaleMappingByProjectId.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,MAAM,UAAU,2BAA2B,CAAC,SAAkB,EAAE,UAAU,GAAG,IAAI;IAC7E,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IAErC,IAAI,MAAqB,CAAC;IAC1B,IAAI,SAAS,EAAE,CAAC;QACZ,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;;YACtC,OAAO,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,0CAAE,WAAW,EAAE,MAAK,SAAS,CAAC,WAAW,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { ENV_VARS } from '../common/constants';
|
|
|
2
2
|
import { MAPPINGS } from '../common/env';
|
|
3
3
|
// NOTE: Dissallowing slash and any whitespace in 2nd capture group.
|
|
4
4
|
const PROJECT_CONFIG_REGEXP = /^([\w-]+):([^/\s]+)(\/[\w.-]+)?$/i;
|
|
5
|
-
export function
|
|
5
|
+
export function getLocaleMappings() {
|
|
6
6
|
const str = MAPPINGS;
|
|
7
7
|
if (!(str === null || str === void 0 ? void 0 : str.length)) {
|
|
8
8
|
throw new Error(`Did you forget to define "${ENV_VARS.MAPPINGS}" environmental variable?
|
|
@@ -27,4 +27,4 @@ export function getProjectLocaleConfigs() {
|
|
|
27
27
|
return config;
|
|
28
28
|
}, {});
|
|
29
29
|
}
|
|
30
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=getLocaleMappings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocaleMappings.js","sourceRoot":"","sources":["../src/utils/getLocaleMappings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAGvC,oEAAoE;AACpE,MAAM,qBAAqB,GAAG,mCAAmC,CAAC;AAGlE,MAAM,UAAU,iBAAiB;IAC7B,MAAM,GAAG,GAAG,QAAQ,CAAC;IACrB,IAAI,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,CAAA,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,QAAQ;8HACwD,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAa,EAAE,EAAE;QAC3D,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,MAAM,OAAO,GAAoB,qBAAqB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3E,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,mIAAmI,CAAC,CAAC;QAC3K,CAAC;QACD,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG;YACX,OAAO,EAAE,KAAK,KAAK,CAAC;YACpB,OAAO;YACP,IAAI;YACJ,MAAM,EAAE,IAAI;SACf,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import Negotiator from 'negotiator';
|
|
2
2
|
import { match as localeMatcher } from '@formatjs/intl-localematcher';
|
|
3
3
|
import { PROJECT_ID_HEADER } from '../common/constants';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { getLocaleMappings } from './getLocaleMappings';
|
|
5
|
+
import { getLocaleMappingByProjectId } from './getLocaleMappingByProjectId';
|
|
6
6
|
export function getRequestLocaleInfo(context) {
|
|
7
7
|
var _a, _b, _c;
|
|
8
8
|
let locale;
|
|
9
|
-
const configs =
|
|
9
|
+
const configs = getLocaleMappings();
|
|
10
10
|
const locales = Object.keys(configs);
|
|
11
11
|
const defaultLocale = locales.find((locale) => configs[locale].default);
|
|
12
12
|
const projectId = (_a = context.headers) === null || _a === void 0 ? void 0 : _a.get(PROJECT_ID_HEADER);
|
|
13
13
|
if (projectId) {
|
|
14
|
-
locale = (_b =
|
|
14
|
+
locale = (_b = getLocaleMappingByProjectId(projectId, false)) === null || _b === void 0 ? void 0 : _b.locale;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
locale = context.locale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestLocaleInfo.js","sourceRoot":"","sources":["../src/utils/getRequestLocaleInfo.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,KAAK,IAAI,aAAa,EAAC,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"getRequestLocaleInfo.js","sourceRoot":"","sources":["../src/utils/getRequestLocaleInfo.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,KAAK,IAAI,aAAa,EAAC,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAG1E,MAAM,UAAU,oBAAoB,CAAC,OAAgB;;IACjD,IAAI,MAAc,CAAC;IACnB,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC1D,IAAI,SAAS,EAAE,CAAC;QACZ,MAAM,GAAG,MAAA,2BAA2B,CAAC,SAAS,EAAE,KAAK,CAAC,0CAAE,MAAM,CAAC;IAEnE,CAAC;SAAM,CAAC;QACJ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,UAAU,GAAG,CAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,iBAAiB,CAAC,KAAI,EAAE,CAAC;YACjE,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAC,OAAO,EAAE,EAAC,iBAAiB,EAAE,UAAU,EAAC,EAAC,CAAC,CAAC,SAAS,EAAE,CAAC;YACrF,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QAC1D,CAAC;IACL,CAAC;IACD,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type {Context, ProjectLocaleConfig} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {PROJECT_ID_HEADER} from '../common/constants';
|
|
5
|
-
import {getProjectLocaleConfigById} from './getProjectLocaleConfigById';
|
|
6
|
-
import {getProjectLocaleConfigByLocale} from './getProjectLocaleConfigByLocale';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export function getProjectLocaleConfig(context: Context): ProjectLocaleConfig {
|
|
10
|
-
const projectId = context.headers?.get(PROJECT_ID_HEADER);
|
|
11
|
-
|
|
12
|
-
let config: ProjectLocaleConfig;
|
|
13
|
-
if (projectId) {
|
|
14
|
-
// first use project id header
|
|
15
|
-
config = getProjectLocaleConfigById(projectId, false);
|
|
16
|
-
}
|
|
17
|
-
if (!config) {
|
|
18
|
-
// next try to use locale from url
|
|
19
|
-
// it will fall back to default locale if not found
|
|
20
|
-
config = getProjectLocaleConfigByLocale(context.locale);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return config;
|
|
24
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type {ProjectLocaleConfig} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {getProjectLocaleConfigs} from './getProjectLocaleConfigs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function getProjectLocaleConfigById(projectId?: string, useDefault = true): ProjectLocaleConfig {
|
|
8
|
-
const configs = getProjectLocaleConfigs();
|
|
9
|
-
|
|
10
|
-
let config: ProjectLocaleConfig;
|
|
11
|
-
if (projectId) {
|
|
12
|
-
config = Object.values(configs).find(p => {
|
|
13
|
-
return p?.project?.toLowerCase() === projectId.toLowerCase();
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
if (!config && useDefault) {
|
|
17
|
-
config = Object.values(configs).find(c => c.default);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return config;
|
|
21
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type {ProjectLocaleConfig} from '../types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {getProjectLocaleConfigs} from './getProjectLocaleConfigs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function getProjectLocaleConfigByLocale(locale?: string, useDefault = true): ProjectLocaleConfig {
|
|
8
|
-
const configs = getProjectLocaleConfigs();
|
|
9
|
-
|
|
10
|
-
let config: ProjectLocaleConfig;
|
|
11
|
-
if (locale) {
|
|
12
|
-
config = configs[locale];
|
|
13
|
-
}
|
|
14
|
-
if (!config && useDefault) {
|
|
15
|
-
config = Object.values(configs).find(c => c.default);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return config;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectLocaleConfig.js","sourceRoot":"","sources":["../src/utils/getProjectLocaleConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAGhF,MAAM,UAAU,sBAAsB,CAAC,OAAgB;;IACnD,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAE1D,IAAI,MAA2B,CAAC;IAChC,IAAI,SAAS,EAAE,CAAC;QACZ,8BAA8B;QAC9B,MAAM,GAAG,0BAA0B,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,kCAAkC;QAClC,mDAAmD;QACnD,MAAM,GAAG,8BAA8B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getProjectLocaleConfigs } from './getProjectLocaleConfigs';
|
|
2
|
-
export function getProjectLocaleConfigById(projectId, useDefault = true) {
|
|
3
|
-
const configs = getProjectLocaleConfigs();
|
|
4
|
-
let config;
|
|
5
|
-
if (projectId) {
|
|
6
|
-
config = Object.values(configs).find(p => {
|
|
7
|
-
var _a;
|
|
8
|
-
return ((_a = p === null || p === void 0 ? void 0 : p.project) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === projectId.toLowerCase();
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!config && useDefault) {
|
|
12
|
-
config = Object.values(configs).find(c => c.default);
|
|
13
|
-
}
|
|
14
|
-
return config;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=getProjectLocaleConfigById.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectLocaleConfigById.js","sourceRoot":"","sources":["../src/utils/getProjectLocaleConfigById.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAGlE,MAAM,UAAU,0BAA0B,CAAC,SAAkB,EAAE,UAAU,GAAG,IAAI;IAC5E,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAE1C,IAAI,MAA2B,CAAC;IAChC,IAAI,SAAS,EAAE,CAAC;QACZ,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;;YACrC,OAAO,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,0CAAE,WAAW,EAAE,MAAK,SAAS,CAAC,WAAW,EAAE,CAAC;QACjE,CAAC,CAAC,CAAC;IACP,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getProjectLocaleConfigs } from './getProjectLocaleConfigs';
|
|
2
|
-
export function getProjectLocaleConfigByLocale(locale, useDefault = true) {
|
|
3
|
-
const configs = getProjectLocaleConfigs();
|
|
4
|
-
let config;
|
|
5
|
-
if (locale) {
|
|
6
|
-
config = configs[locale];
|
|
7
|
-
}
|
|
8
|
-
if (!config && useDefault) {
|
|
9
|
-
config = Object.values(configs).find(c => c.default);
|
|
10
|
-
}
|
|
11
|
-
return config;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=getProjectLocaleConfigByLocale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectLocaleConfigByLocale.js","sourceRoot":"","sources":["../src/utils/getProjectLocaleConfigByLocale.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAGlE,MAAM,UAAU,8BAA8B,CAAC,MAAe,EAAE,UAAU,GAAG,IAAI;IAC7E,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAE1C,IAAI,MAA2B,CAAC;IAChC,IAAI,MAAM,EAAE,CAAC;QACT,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
|