intor 2.3.1 → 2.3.2
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/exports/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
export { PREFIX_PLACEHOLDER } from "../src/shared/constants/prefix-placeholder";
|
|
3
3
|
export { mergeMessages, normalizeCacheKey, resolveNamespaces, normalizeLocale, resolvePreferredLocale, extractPathname, normalizePathname, standardizePathname, } from "../src/shared/utils";
|
|
4
4
|
export { IntorError, IntorErrorCode } from "../src/shared/error";
|
|
5
|
-
export { Translator, type TranslateHandlers, type FormatHandler, type LoadingHandler, type MissingHandler, type
|
|
5
|
+
export { Translator, type TranslatorOptions, type TranslatorMethods, type TranslatorPlugin, type TranslateConfig, type TranslateHandlers, type FormatHandler, type LoadingHandler, type MissingHandler, type HandlerContext, type TranslateContext, type TranslateHook, type Locale, type FallbackLocalesMap, type NestedMessage, type LocaleMessages, type LocalizedMessagesUnion, type Replacement, type DefaultDepth, type NodeKeys, type LeafKeys, type LocalizedNodeKeys, type LocalizedLeafKeys, type ScopedLeafKeys, } from "intor-translator";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { TranslatorContextValue } from "./types";
|
|
2
|
-
|
|
2
|
+
import type { LocaleMessages } from "intor-translator";
|
|
3
|
+
export declare function useTranslator<M extends LocaleMessages = LocaleMessages>(): TranslatorContextValue<M>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Translator } from "intor-translator";
|
|
1
|
+
import type { LocaleMessages, Translator } from "intor-translator";
|
|
2
2
|
import type * as React from "react";
|
|
3
|
-
export type TranslatorContextValue<M =
|
|
3
|
+
export type TranslatorContextValue<M extends LocaleMessages = LocaleMessages> = {
|
|
4
4
|
translator: Translator<M>;
|
|
5
5
|
};
|
|
6
6
|
export type TranslatorProviderProps = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IfGen } from "../../shared/types/generated.types";
|
|
2
|
-
import { type Locale, type Replacement, type ScopedLeafKeys, type LocalizedLeafKeys } from "intor-translator";
|
|
2
|
+
import { type Locale, type Replacement, type ScopedLeafKeys, type LocalizedLeafKeys, type LocaleMessages } from "intor-translator";
|
|
3
3
|
/** Base properties shared by all translator instances. */
|
|
4
4
|
export interface TranslatorBaseProps<M = unknown> {
|
|
5
5
|
/** `messages`: The message object containing all translations. */
|
|
@@ -19,12 +19,12 @@ export interface TranslatorClientProps<M = unknown> {
|
|
|
19
19
|
* - Resolves to `ScopedLeafKeys` if a pre-key `PK` is provided,
|
|
20
20
|
* otherwise resolves to `LocalizedLeafKeys`.
|
|
21
21
|
*/
|
|
22
|
-
type Key<M, PK> = IfGen<PK extends string ? ScopedLeafKeys<M, PK> : LocalizedLeafKeys<M>, string>;
|
|
22
|
+
type Key<M extends LocaleMessages, PK> = IfGen<PK extends string ? ScopedLeafKeys<M, PK> : LocalizedLeafKeys<M>, string>;
|
|
23
23
|
/**
|
|
24
24
|
* Translator instance type.
|
|
25
25
|
* Combines base props, client props, and core translation methods.
|
|
26
26
|
*/
|
|
27
|
-
export type TranslatorInstance<M, PK extends string | undefined = undefined> = {
|
|
27
|
+
export type TranslatorInstance<M extends LocaleMessages, PK extends string | undefined = undefined> = {
|
|
28
28
|
/** Check if a given key exists in the messages. */
|
|
29
29
|
hasKey: (key?: Key<M, PK>, targetLocale?: Locale<M>) => boolean;
|
|
30
30
|
/** Translate a given key into its string representation. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intor",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
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",
|
|
@@ -78,10 +78,11 @@
|
|
|
78
78
|
"build:next": "rollup -c .config/rollup/next.js",
|
|
79
79
|
"build:dts": "rollup -c .config/rollup/dts.js",
|
|
80
80
|
"build": "yarn clean && yarn build:core && yarn build:react && yarn build:next && yarn tsc -p tsconfig.build.json && yarn tsc-alias tsconfig.build.json --outDir dist",
|
|
81
|
-
"prepublishOnly": "yarn build"
|
|
81
|
+
"prepublishOnly": "yarn build",
|
|
82
|
+
"examples:html": "vite --config examples/html/vite.config.ts"
|
|
82
83
|
},
|
|
83
84
|
"dependencies": {
|
|
84
|
-
"intor-translator": "^1.
|
|
85
|
+
"intor-translator": "^1.2.0",
|
|
85
86
|
"keyv": "^5.5.3",
|
|
86
87
|
"lodash.merge": "^4.6.2",
|
|
87
88
|
"logry": "^2.0.1",
|
|
@@ -115,6 +116,7 @@
|
|
|
115
116
|
"tsc-alias": "^1.8.16",
|
|
116
117
|
"typescript": "^5.8.3",
|
|
117
118
|
"typescript-eslint": "^8.32.1",
|
|
119
|
+
"vite": "^7.2.6",
|
|
118
120
|
"vitest": "^4.0.9"
|
|
119
121
|
},
|
|
120
122
|
"sideEffects": false,
|