intor 1.0.14 → 1.0.16
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/index.cjs +17 -0
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +17 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var path = require('path');
|
|
|
6
6
|
var perf_hooks = require('perf_hooks');
|
|
7
7
|
var pLimit = require('p-limit');
|
|
8
8
|
var fs = require('fs/promises');
|
|
9
|
+
var intorTranslator = require('intor-translator');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
|
|
@@ -1134,9 +1135,25 @@ var intor = async ({
|
|
|
1134
1135
|
}
|
|
1135
1136
|
}
|
|
1136
1137
|
};
|
|
1138
|
+
var createIntor = (config, translateHandlers) => {
|
|
1139
|
+
return async (request) => {
|
|
1140
|
+
var _a, _b;
|
|
1141
|
+
const { initialLocale, messages } = await intor({ config, request });
|
|
1142
|
+
const translator = new intorTranslator.Translator({
|
|
1143
|
+
locale: initialLocale,
|
|
1144
|
+
messages,
|
|
1145
|
+
fallbackLocales: config.fallbackLocales,
|
|
1146
|
+
loadingMessage: (_a = config.translator) == null ? void 0 : _a.loadingMessage,
|
|
1147
|
+
placeholder: (_b = config.translator) == null ? void 0 : _b.placeholder,
|
|
1148
|
+
handlers: translateHandlers
|
|
1149
|
+
});
|
|
1150
|
+
return translator;
|
|
1151
|
+
};
|
|
1152
|
+
};
|
|
1137
1153
|
|
|
1138
1154
|
exports.IntorError = IntorError;
|
|
1139
1155
|
exports.IntorErrorCode = IntorErrorCode;
|
|
1156
|
+
exports.createIntor = createIntor;
|
|
1140
1157
|
exports.defineIntorConfig = defineIntorConfig;
|
|
1141
1158
|
exports.extractPathname = extractPathname;
|
|
1142
1159
|
exports.fetchApiMessages = fetchApiMessages;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry';
|
|
2
|
-
import { Locale, LocaleNamespaceMessages, FallbackLocalesMap } from 'intor-translator';
|
|
2
|
+
import { Locale, LocaleNamespaceMessages, FallbackLocalesMap, TranslateHandlers, Translator } from 'intor-translator';
|
|
3
3
|
export { FormatMessage, OnLoading, OnMissing, TranslateContext, TranslateHandlers } from 'intor-translator';
|
|
4
|
+
import { NextRequest } from 'next/server';
|
|
4
5
|
|
|
5
6
|
type InitCookieOptions = {
|
|
6
7
|
disabled?: boolean;
|
|
@@ -291,4 +292,6 @@ type IntorAdapterRuntime = (options: {
|
|
|
291
292
|
pathname: string;
|
|
292
293
|
}>;
|
|
293
294
|
|
|
294
|
-
|
|
295
|
+
declare const createIntor: <M = unknown>(config: IntorResolvedConfig, translateHandlers?: TranslateHandlers) => ((request?: NextRequest) => Promise<Translator<M>>);
|
|
296
|
+
|
|
297
|
+
export { type FetchApiMessagesOptions, type IntorAdapterRuntime, IntorError, IntorErrorCode, type IntorResolvedConfig, type LoaderOptions, type ResolvedCookieOptions, createIntor, defineIntorConfig, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry';
|
|
2
|
-
import { Locale, LocaleNamespaceMessages, FallbackLocalesMap } from 'intor-translator';
|
|
2
|
+
import { Locale, LocaleNamespaceMessages, FallbackLocalesMap, TranslateHandlers, Translator } from 'intor-translator';
|
|
3
3
|
export { FormatMessage, OnLoading, OnMissing, TranslateContext, TranslateHandlers } from 'intor-translator';
|
|
4
|
+
import { NextRequest } from 'next/server';
|
|
4
5
|
|
|
5
6
|
type InitCookieOptions = {
|
|
6
7
|
disabled?: boolean;
|
|
@@ -291,4 +292,6 @@ type IntorAdapterRuntime = (options: {
|
|
|
291
292
|
pathname: string;
|
|
292
293
|
}>;
|
|
293
294
|
|
|
294
|
-
|
|
295
|
+
declare const createIntor: <M = unknown>(config: IntorResolvedConfig, translateHandlers?: TranslateHandlers) => ((request?: NextRequest) => Promise<Translator<M>>);
|
|
296
|
+
|
|
297
|
+
export { type FetchApiMessagesOptions, type IntorAdapterRuntime, IntorError, IntorErrorCode, type IntorResolvedConfig, type LoaderOptions, type ResolvedCookieOptions, createIntor, defineIntorConfig, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { performance } from 'perf_hooks';
|
|
5
5
|
import pLimit from 'p-limit';
|
|
6
6
|
import fs from 'fs/promises';
|
|
7
|
+
import { Translator } from 'intor-translator';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __defProps = Object.defineProperties;
|
|
@@ -1126,5 +1127,20 @@ var intor = async ({
|
|
|
1126
1127
|
}
|
|
1127
1128
|
}
|
|
1128
1129
|
};
|
|
1130
|
+
var createIntor = (config, translateHandlers) => {
|
|
1131
|
+
return async (request) => {
|
|
1132
|
+
var _a, _b;
|
|
1133
|
+
const { initialLocale, messages } = await intor({ config, request });
|
|
1134
|
+
const translator = new Translator({
|
|
1135
|
+
locale: initialLocale,
|
|
1136
|
+
messages,
|
|
1137
|
+
fallbackLocales: config.fallbackLocales,
|
|
1138
|
+
loadingMessage: (_a = config.translator) == null ? void 0 : _a.loadingMessage,
|
|
1139
|
+
placeholder: (_b = config.translator) == null ? void 0 : _b.placeholder,
|
|
1140
|
+
handlers: translateHandlers
|
|
1141
|
+
});
|
|
1142
|
+
return translator;
|
|
1143
|
+
};
|
|
1144
|
+
};
|
|
1129
1145
|
|
|
1130
|
-
export { IntorError, IntorErrorCode, defineIntorConfig, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
|
|
1146
|
+
export { IntorError, IntorErrorCode, createIntor, defineIntorConfig, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "A modular and extensible i18n core designed for TypeScript and JavaScript projects. Intor enables custom translation logic with support for both frontend and backend environments, featuring runtime configuration, caching, adapters, and message loaders.",
|
|
5
5
|
"author": "Yiming Liao",
|
|
6
6
|
"license": "MIT",
|