intor 1.0.24 → 1.0.26

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 CHANGED
@@ -967,6 +967,21 @@ var intor = async ({
967
967
  }
968
968
  }
969
969
  };
970
+ var createIntor = (config, translateHandlers) => {
971
+ return async (request) => {
972
+ var _a, _b;
973
+ const { initialLocale, messages } = await intor({ config, request });
974
+ const translator = new intorTranslator.Translator({
975
+ locale: initialLocale,
976
+ messages,
977
+ fallbackLocales: config.fallbackLocales,
978
+ loadingMessage: (_a = config.translator) == null ? void 0 : _a.loadingMessage,
979
+ placeholder: (_b = config.translator) == null ? void 0 : _b.placeholder,
980
+ handlers: translateHandlers
981
+ });
982
+ return translator;
983
+ };
984
+ };
970
985
 
971
986
  Object.defineProperty(exports, "Translator", {
972
987
  enumerable: true,
@@ -974,6 +989,7 @@ Object.defineProperty(exports, "Translator", {
974
989
  });
975
990
  exports.IntorError = IntorError;
976
991
  exports.IntorErrorCode = IntorErrorCode;
992
+ exports.createIntor = createIntor;
977
993
  exports.extractPathname = extractPathname;
978
994
  exports.fetchApiMessages = fetchApiMessages;
979
995
  exports.intor = intor;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { Locale, LocaleNamespaceMessages, FallbackLocalesMap } from 'intor-translator';
1
+ import { Locale, LocaleNamespaceMessages, FallbackLocalesMap, TranslateHandlers, Translator } from 'intor-translator';
2
2
  export { FormatMessage, OnLoading, OnMissing, TranslateContext, TranslateHandlers, Translator } from 'intor-translator';
3
+ import { NextRequest } from 'next/server';
3
4
 
4
5
  type InitCookieOptions = {
5
6
  disabled?: boolean;
@@ -266,4 +267,6 @@ type IntorAdapterRuntime = (options: {
266
267
  pathname: string;
267
268
  }>;
268
269
 
269
- export { type FetchApiMessagesOptions, type IntorAdapterRuntime, IntorError, IntorErrorCode, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
270
+ declare const createIntor: <M = unknown>(config: IntorResolvedConfig, translateHandlers?: TranslateHandlers) => ((request?: NextRequest) => Promise<Translator<M>>);
271
+
272
+ export { type FetchApiMessagesOptions, type IntorAdapterRuntime, IntorError, IntorErrorCode, createIntor, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { Locale, LocaleNamespaceMessages, FallbackLocalesMap } from 'intor-translator';
1
+ import { Locale, LocaleNamespaceMessages, FallbackLocalesMap, TranslateHandlers, Translator } from 'intor-translator';
2
2
  export { FormatMessage, OnLoading, OnMissing, TranslateContext, TranslateHandlers, Translator } from 'intor-translator';
3
+ import { NextRequest } from 'next/server';
3
4
 
4
5
  type InitCookieOptions = {
5
6
  disabled?: boolean;
@@ -266,4 +267,6 @@ type IntorAdapterRuntime = (options: {
266
267
  pathname: string;
267
268
  }>;
268
269
 
269
- export { type FetchApiMessagesOptions, type IntorAdapterRuntime, IntorError, IntorErrorCode, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
270
+ declare const createIntor: <M = unknown>(config: IntorResolvedConfig, translateHandlers?: TranslateHandlers) => ((request?: NextRequest) => Promise<Translator<M>>);
271
+
272
+ export { type FetchApiMessagesOptions, type IntorAdapterRuntime, IntorError, IntorErrorCode, createIntor, 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
  export { Translator } from 'intor-translator';
8
9
 
9
10
  var __defProp = Object.defineProperty;
@@ -959,5 +960,20 @@ var intor = async ({
959
960
  }
960
961
  }
961
962
  };
963
+ var createIntor = (config, translateHandlers) => {
964
+ return async (request) => {
965
+ var _a, _b;
966
+ const { initialLocale, messages } = await intor({ config, request });
967
+ const translator = new Translator({
968
+ locale: initialLocale,
969
+ messages,
970
+ fallbackLocales: config.fallbackLocales,
971
+ loadingMessage: (_a = config.translator) == null ? void 0 : _a.loadingMessage,
972
+ placeholder: (_b = config.translator) == null ? void 0 : _b.placeholder,
973
+ handlers: translateHandlers
974
+ });
975
+ return translator;
976
+ };
977
+ };
962
978
 
963
- export { IntorError, IntorErrorCode, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };
979
+ export { IntorError, IntorErrorCode, createIntor, extractPathname, fetchApiMessages, intor, loadLocalMessages, mergeStaticAndDynamicMessages, normalizeLocale, normalizePathname, resolveNamespaces, resolvePreferredLocale, standardizePathname };