intor 2.4.10 → 2.4.11
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/dist/core/export/index.js +2 -6
- package/dist/core/export/internal/index.js +6 -0
- package/dist/core/src/core/constants/locale-placeholder.js +4 -0
- package/dist/core/src/routing/pathname/canonicalize-pathname.js +3 -3
- package/dist/core/src/routing/pathname/materialize-pathname.js +5 -5
- package/dist/core/src/routing/pathname/standardize-pathname.js +2 -2
- package/dist/express/src/core/constants/locale-placeholder.js +4 -0
- package/dist/express/src/routing/pathname/canonicalize-pathname.js +3 -3
- package/dist/express/src/routing/pathname/materialize-pathname.js +5 -5
- package/dist/express/src/routing/pathname/standardize-pathname.js +2 -2
- package/dist/fastify/src/core/constants/locale-placeholder.js +4 -0
- package/dist/fastify/src/routing/pathname/canonicalize-pathname.js +3 -3
- package/dist/fastify/src/routing/pathname/materialize-pathname.js +5 -5
- package/dist/fastify/src/routing/pathname/standardize-pathname.js +2 -2
- package/dist/hono/src/core/constants/locale-placeholder.js +4 -0
- package/dist/hono/src/routing/pathname/canonicalize-pathname.js +3 -3
- package/dist/hono/src/routing/pathname/materialize-pathname.js +5 -5
- package/dist/hono/src/routing/pathname/standardize-pathname.js +2 -2
- package/dist/next/src/core/constants/locale-placeholder.js +4 -0
- package/dist/next/src/routing/pathname/canonicalize-pathname.js +3 -3
- package/dist/next/src/routing/pathname/materialize-pathname.js +5 -5
- package/dist/next/src/routing/pathname/standardize-pathname.js +2 -2
- package/dist/svelte-kit/src/core/constants/locale-placeholder.js +4 -0
- package/dist/svelte-kit/src/routing/pathname/canonicalize-pathname.js +3 -3
- package/dist/svelte-kit/src/routing/pathname/materialize-pathname.js +5 -5
- package/dist/svelte-kit/src/routing/pathname/standardize-pathname.js +2 -2
- package/dist/types/export/index.d.ts +1 -2
- package/dist/types/export/internal/index.d.ts +4 -0
- package/dist/types/src/core/constants/index.d.ts +1 -1
- package/dist/types/src/core/constants/locale-placeholder.d.ts +1 -0
- package/dist/types/src/core/index.d.ts +1 -1
- package/dist/types/src/core/types/generated.d.ts +2 -2
- package/package.json +5 -4
- package/dist/core/src/core/constants/prefix-placeholder.js +0 -4
- package/dist/express/src/core/constants/prefix-placeholder.js +0 -4
- package/dist/fastify/src/core/constants/prefix-placeholder.js +0 -4
- package/dist/hono/src/core/constants/prefix-placeholder.js +0 -4
- package/dist/next/src/core/constants/prefix-placeholder.js +0 -4
- package/dist/svelte-kit/src/core/constants/prefix-placeholder.js +0 -4
- package/dist/types/src/core/constants/prefix-placeholder.d.ts +0 -1
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LOCALE_PLACEHOLDER } from '../src/core/constants/locale-placeholder.js';
|
|
2
2
|
export { IntorError, IntorErrorCode } from '../src/core/error/intor-error.js';
|
|
3
|
-
export { deepMerge } from '../src/core/utils/deep-merge.js';
|
|
4
|
-
export { resolveLoaderOptions } from '../src/core/utils/resolve-loader-options.js';
|
|
5
3
|
import 'logry';
|
|
6
4
|
export { clearLoggerPool } from '../src/core/logger/global-logger-pool.js';
|
|
7
5
|
import 'p-limit';
|
|
8
|
-
export { isValidMessages } from '../src/core/messages/utils/is-valid-messages.js';
|
|
9
6
|
export { mergeMessages } from '../src/core/messages/merge-messages.js';
|
|
10
|
-
|
|
11
|
-
export { Translator, tokenize } from 'intor-translator';
|
|
7
|
+
import 'intor-translator';
|
|
12
8
|
export { defineIntorConfig } from '../src/config/define-intor-config.js';
|
|
13
9
|
import '../src/config/constants/cookie.js';
|
|
14
10
|
export { localizePathname } from '../src/routing/pathname/localize-pathname.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '../../src/core/error/intor-error.js';
|
|
2
|
+
export { resolveLoaderOptions } from '../../src/core/utils/resolve-loader-options.js';
|
|
3
|
+
import 'logry';
|
|
4
|
+
import 'p-limit';
|
|
5
|
+
export { INTOR_MESSAGES_KIND, INTOR_MESSAGES_KIND_KEY, INTOR_PREFIX, getMessagesKind } from '../../src/core/messages/internal-metadata.js';
|
|
6
|
+
import 'intor-translator';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
|
|
|
33
33
|
}
|
|
34
34
|
// Detect locale segment
|
|
35
35
|
const firstSegment = prefixedPathname.split("/").find(Boolean);
|
|
36
|
-
const locale = firstSegment ===
|
|
37
|
-
?
|
|
36
|
+
const locale = firstSegment === LOCALE_PLACEHOLDER
|
|
37
|
+
? LOCALE_PLACEHOLDER
|
|
38
38
|
: firstSegment && supportedLocales.includes(firstSegment)
|
|
39
39
|
? firstSegment
|
|
40
40
|
: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
|
|
|
27
27
|
}
|
|
28
28
|
// localePrefix: "all"
|
|
29
29
|
if (localePrefix === "all") {
|
|
30
|
-
return normalizePathname(standardizedPathname.replaceAll(
|
|
30
|
+
return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
31
31
|
}
|
|
32
32
|
// localePrefix: "except-default"
|
|
33
33
|
if (localePrefix === "except-default") {
|
|
34
34
|
return locale === config.defaultLocale
|
|
35
|
-
? normalizePathname(standardizedPathname.replaceAll(`/${
|
|
36
|
-
: normalizePathname(standardizedPathname.replaceAll(
|
|
35
|
+
? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
|
|
36
|
+
: normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
37
37
|
}
|
|
38
38
|
// localePrefix: "none"
|
|
39
|
-
return normalizePathname(standardizedPathname.replaceAll(`/${
|
|
39
|
+
return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { materializePathname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
|
|
|
22
22
|
// Normalize each segment before join to avoid redundant slashes
|
|
23
23
|
const parts = [
|
|
24
24
|
normalizePathname(basePath),
|
|
25
|
-
|
|
25
|
+
LOCALE_PLACEHOLDER,
|
|
26
26
|
normalizePathname(canonicalizedPathname),
|
|
27
27
|
];
|
|
28
28
|
// Avoid double slashes between segments
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
|
|
|
33
33
|
}
|
|
34
34
|
// Detect locale segment
|
|
35
35
|
const firstSegment = prefixedPathname.split("/").find(Boolean);
|
|
36
|
-
const locale = firstSegment ===
|
|
37
|
-
?
|
|
36
|
+
const locale = firstSegment === LOCALE_PLACEHOLDER
|
|
37
|
+
? LOCALE_PLACEHOLDER
|
|
38
38
|
: firstSegment && supportedLocales.includes(firstSegment)
|
|
39
39
|
? firstSegment
|
|
40
40
|
: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
|
|
|
27
27
|
}
|
|
28
28
|
// localePrefix: "all"
|
|
29
29
|
if (localePrefix === "all") {
|
|
30
|
-
return normalizePathname(standardizedPathname.replaceAll(
|
|
30
|
+
return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
31
31
|
}
|
|
32
32
|
// localePrefix: "except-default"
|
|
33
33
|
if (localePrefix === "except-default") {
|
|
34
34
|
return locale === config.defaultLocale
|
|
35
|
-
? normalizePathname(standardizedPathname.replaceAll(`/${
|
|
36
|
-
: normalizePathname(standardizedPathname.replaceAll(
|
|
35
|
+
? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
|
|
36
|
+
: normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
37
37
|
}
|
|
38
38
|
// localePrefix: "none"
|
|
39
|
-
return normalizePathname(standardizedPathname.replaceAll(`/${
|
|
39
|
+
return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { materializePathname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
|
|
|
22
22
|
// Normalize each segment before join to avoid redundant slashes
|
|
23
23
|
const parts = [
|
|
24
24
|
normalizePathname(basePath),
|
|
25
|
-
|
|
25
|
+
LOCALE_PLACEHOLDER,
|
|
26
26
|
normalizePathname(canonicalizedPathname),
|
|
27
27
|
];
|
|
28
28
|
// Avoid double slashes between segments
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
|
|
|
33
33
|
}
|
|
34
34
|
// Detect locale segment
|
|
35
35
|
const firstSegment = prefixedPathname.split("/").find(Boolean);
|
|
36
|
-
const locale = firstSegment ===
|
|
37
|
-
?
|
|
36
|
+
const locale = firstSegment === LOCALE_PLACEHOLDER
|
|
37
|
+
? LOCALE_PLACEHOLDER
|
|
38
38
|
: firstSegment && supportedLocales.includes(firstSegment)
|
|
39
39
|
? firstSegment
|
|
40
40
|
: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
|
|
|
27
27
|
}
|
|
28
28
|
// localePrefix: "all"
|
|
29
29
|
if (localePrefix === "all") {
|
|
30
|
-
return normalizePathname(standardizedPathname.replaceAll(
|
|
30
|
+
return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
31
31
|
}
|
|
32
32
|
// localePrefix: "except-default"
|
|
33
33
|
if (localePrefix === "except-default") {
|
|
34
34
|
return locale === config.defaultLocale
|
|
35
|
-
? normalizePathname(standardizedPathname.replaceAll(`/${
|
|
36
|
-
: normalizePathname(standardizedPathname.replaceAll(
|
|
35
|
+
? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
|
|
36
|
+
: normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
37
37
|
}
|
|
38
38
|
// localePrefix: "none"
|
|
39
|
-
return normalizePathname(standardizedPathname.replaceAll(`/${
|
|
39
|
+
return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { materializePathname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
|
|
|
22
22
|
// Normalize each segment before join to avoid redundant slashes
|
|
23
23
|
const parts = [
|
|
24
24
|
normalizePathname(basePath),
|
|
25
|
-
|
|
25
|
+
LOCALE_PLACEHOLDER,
|
|
26
26
|
normalizePathname(canonicalizedPathname),
|
|
27
27
|
];
|
|
28
28
|
// Avoid double slashes between segments
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
|
|
|
33
33
|
}
|
|
34
34
|
// Detect locale segment
|
|
35
35
|
const firstSegment = prefixedPathname.split("/").find(Boolean);
|
|
36
|
-
const locale = firstSegment ===
|
|
37
|
-
?
|
|
36
|
+
const locale = firstSegment === LOCALE_PLACEHOLDER
|
|
37
|
+
? LOCALE_PLACEHOLDER
|
|
38
38
|
: firstSegment && supportedLocales.includes(firstSegment)
|
|
39
39
|
? firstSegment
|
|
40
40
|
: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
|
|
|
27
27
|
}
|
|
28
28
|
// localePrefix: "all"
|
|
29
29
|
if (localePrefix === "all") {
|
|
30
|
-
return normalizePathname(standardizedPathname.replaceAll(
|
|
30
|
+
return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
31
31
|
}
|
|
32
32
|
// localePrefix: "except-default"
|
|
33
33
|
if (localePrefix === "except-default") {
|
|
34
34
|
return locale === config.defaultLocale
|
|
35
|
-
? normalizePathname(standardizedPathname.replaceAll(`/${
|
|
36
|
-
: normalizePathname(standardizedPathname.replaceAll(
|
|
35
|
+
? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
|
|
36
|
+
: normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
37
37
|
}
|
|
38
38
|
// localePrefix: "none"
|
|
39
|
-
return normalizePathname(standardizedPathname.replaceAll(`/${
|
|
39
|
+
return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { materializePathname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
|
|
|
22
22
|
// Normalize each segment before join to avoid redundant slashes
|
|
23
23
|
const parts = [
|
|
24
24
|
normalizePathname(basePath),
|
|
25
|
-
|
|
25
|
+
LOCALE_PLACEHOLDER,
|
|
26
26
|
normalizePathname(canonicalizedPathname),
|
|
27
27
|
];
|
|
28
28
|
// Avoid double slashes between segments
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
|
|
|
33
33
|
}
|
|
34
34
|
// Detect locale segment
|
|
35
35
|
const firstSegment = prefixedPathname.split("/").find(Boolean);
|
|
36
|
-
const locale = firstSegment ===
|
|
37
|
-
?
|
|
36
|
+
const locale = firstSegment === LOCALE_PLACEHOLDER
|
|
37
|
+
? LOCALE_PLACEHOLDER
|
|
38
38
|
: firstSegment && supportedLocales.includes(firstSegment)
|
|
39
39
|
? firstSegment
|
|
40
40
|
: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
|
|
|
27
27
|
}
|
|
28
28
|
// localePrefix: "all"
|
|
29
29
|
if (localePrefix === "all") {
|
|
30
|
-
return normalizePathname(standardizedPathname.replaceAll(
|
|
30
|
+
return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
31
31
|
}
|
|
32
32
|
// localePrefix: "except-default"
|
|
33
33
|
if (localePrefix === "except-default") {
|
|
34
34
|
return locale === config.defaultLocale
|
|
35
|
-
? normalizePathname(standardizedPathname.replaceAll(`/${
|
|
36
|
-
: normalizePathname(standardizedPathname.replaceAll(
|
|
35
|
+
? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
|
|
36
|
+
: normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
37
37
|
}
|
|
38
38
|
// localePrefix: "none"
|
|
39
|
-
return normalizePathname(standardizedPathname.replaceAll(`/${
|
|
39
|
+
return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { materializePathname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
|
|
|
22
22
|
// Normalize each segment before join to avoid redundant slashes
|
|
23
23
|
const parts = [
|
|
24
24
|
normalizePathname(basePath),
|
|
25
|
-
|
|
25
|
+
LOCALE_PLACEHOLDER,
|
|
26
26
|
normalizePathname(canonicalizedPathname),
|
|
27
27
|
];
|
|
28
28
|
// Avoid double slashes between segments
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -33,8 +33,8 @@ function canonicalizePathname(rawPathname, config) {
|
|
|
33
33
|
}
|
|
34
34
|
// Detect locale segment
|
|
35
35
|
const firstSegment = prefixedPathname.split("/").find(Boolean);
|
|
36
|
-
const locale = firstSegment ===
|
|
37
|
-
?
|
|
36
|
+
const locale = firstSegment === LOCALE_PLACEHOLDER
|
|
37
|
+
? LOCALE_PLACEHOLDER
|
|
38
38
|
: firstSegment && supportedLocales.includes(firstSegment)
|
|
39
39
|
? firstSegment
|
|
40
40
|
: undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -27,16 +27,16 @@ const materializePathname = (standardizedPathname, config, locale) => {
|
|
|
27
27
|
}
|
|
28
28
|
// localePrefix: "all"
|
|
29
29
|
if (localePrefix === "all") {
|
|
30
|
-
return normalizePathname(standardizedPathname.replaceAll(
|
|
30
|
+
return normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
31
31
|
}
|
|
32
32
|
// localePrefix: "except-default"
|
|
33
33
|
if (localePrefix === "except-default") {
|
|
34
34
|
return locale === config.defaultLocale
|
|
35
|
-
? normalizePathname(standardizedPathname.replaceAll(`/${
|
|
36
|
-
: normalizePathname(standardizedPathname.replaceAll(
|
|
35
|
+
? normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""))
|
|
36
|
+
: normalizePathname(standardizedPathname.replaceAll(LOCALE_PLACEHOLDER, locale));
|
|
37
37
|
}
|
|
38
38
|
// localePrefix: "none"
|
|
39
|
-
return normalizePathname(standardizedPathname.replaceAll(`/${
|
|
39
|
+
return normalizePathname(standardizedPathname.replaceAll(`/${LOCALE_PLACEHOLDER}`, ""));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export { materializePathname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCALE_PLACEHOLDER } from '../../core/constants/locale-placeholder.js';
|
|
2
2
|
import '../../core/error/intor-error.js';
|
|
3
3
|
import { normalizePathname } from '../../core/utils/normalizers/normalize-pathname.js';
|
|
4
4
|
import 'logry';
|
|
@@ -22,7 +22,7 @@ const standardizePathname = (canonicalizedPathname, config) => {
|
|
|
22
22
|
// Normalize each segment before join to avoid redundant slashes
|
|
23
23
|
const parts = [
|
|
24
24
|
normalizePathname(basePath),
|
|
25
|
-
|
|
25
|
+
LOCALE_PLACEHOLDER,
|
|
26
26
|
normalizePathname(canonicalizedPathname),
|
|
27
27
|
];
|
|
28
28
|
// Avoid double slashes between segments
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LOCALE_PLACEHOLDER, IntorError, IntorErrorCode, clearLoggerPool, mergeMessages, type MessagesReader, type MessagesReaders, type GenLocale as Locale, } from "../src/core";
|
|
2
2
|
export { defineIntorConfig, type IntorRawConfig, type IntorResolvedConfig, } from "../src/config";
|
|
3
3
|
export { localizePathname, type InboundContext } from "../src/routing";
|
|
4
|
-
export { Translator, type TranslatorPlugin, type TranslateContext, type TranslateHook, type TranslateHandlers, type HandlerContext, type FormatHandler, type LoadingHandler, type MissingHandler, type LocaleMessages, type MessageObject, type MessageValue, tokenize, type Token, } from "intor-translator";
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: It is not part of the public stable contract and may change without notice.
|
|
3
|
+
*/
|
|
4
|
+
export { resolveLoaderOptions, INTOR_PREFIX, INTOR_MESSAGES_KIND_KEY, INTOR_MESSAGES_KIND, getMessagesKind, type IntorMessagesKind, } from "../../src/core";
|
|
1
5
|
export type { GenConfigKeys, GenConfig, TranslatorInstance, } from "../../src/core";
|
|
2
6
|
export type { TranslatorInstanceReact } from "../../src/client/react/translator/translator-instance";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LOCALE_PLACEHOLDER } from "./locale-placeholder";
|
|
2
2
|
export { INTOR_HEADERS } from "./headers";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LOCALE_PLACEHOLDER = "{locale}";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LOCALE_PLACEHOLDER, INTOR_HEADERS } from "./constants";
|
|
2
2
|
export { IntorError, IntorErrorCode } from "./error";
|
|
3
3
|
export { deepMerge, type PlainObject, type DeepMergeOverrideEvent, resolveLoaderOptions, parseCookieHeader, normalizePathname, normalizeCacheKey, normalizeLocale, normalizeQuery, type NormalizedQuery, } from "./utils";
|
|
4
4
|
export { getLogger, clearLoggerPool } from "./logger";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LOCALE_PLACEHOLDER } from "../constants";
|
|
2
2
|
import type { Locale, LocaleMessages, Replacement, Rich } from "intor-translator";
|
|
3
3
|
/**
|
|
4
4
|
* =================================================
|
|
@@ -40,7 +40,7 @@ type FallbackConfig = {
|
|
|
40
40
|
*/
|
|
41
41
|
type ExtractGeneratedConfig<T> = T extends {
|
|
42
42
|
Locales: infer L extends string;
|
|
43
|
-
Messages: Record<typeof
|
|
43
|
+
Messages: Record<typeof LOCALE_PLACEHOLDER, infer M>;
|
|
44
44
|
Replacements: infer RE;
|
|
45
45
|
Rich: infer RI;
|
|
46
46
|
} ? {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intor",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.11",
|
|
4
4
|
"description": "The i18n library for modern JavaScript",
|
|
5
5
|
"author": "Yiming Liao",
|
|
6
6
|
"homepage": "https://intor.dev",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"require": "./dist/core/export/index.js",
|
|
37
37
|
"default": "./dist/core/export/index.js"
|
|
38
38
|
},
|
|
39
|
+
"./internal": {
|
|
40
|
+
"import": "./dist/core/export/internal/index.js",
|
|
41
|
+
"types": "./dist/types/export/internal/index.d.ts"
|
|
42
|
+
},
|
|
39
43
|
"./server": {
|
|
40
44
|
"import": "./dist/core/export/server/index.js",
|
|
41
45
|
"types": "./dist/types/export/server/index.d.ts",
|
|
@@ -46,9 +50,6 @@
|
|
|
46
50
|
"import": "./dist/core/export/edge/index.js",
|
|
47
51
|
"types": "./dist/types/export/edge/index.d.ts"
|
|
48
52
|
},
|
|
49
|
-
"./internal": {
|
|
50
|
-
"types": "./dist/types/export/internal/index.d.ts"
|
|
51
|
-
},
|
|
52
53
|
"./react": {
|
|
53
54
|
"import": "./dist/react/export/react/index.js",
|
|
54
55
|
"types": "./dist/types/export/react/index.d.ts"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PREFIX_PLACEHOLDER = "{locale}";
|