gt-node 0.6.3 → 0.6.5
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/CHANGELOG.md +20 -0
- package/dist/AsyncStorageAdapter-D852UaVa.mjs +71 -0
- package/dist/AsyncStorageAdapter-D852UaVa.mjs.map +1 -0
- package/dist/AsyncStorageAdapter-xUXP4qma.cjs +100 -0
- package/dist/AsyncStorageAdapter-xUXP4qma.cjs.map +1 -0
- package/dist/index.cjs +179 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +12 -18
- package/dist/index.d.mts +48 -0
- package/dist/index.mjs +86 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal.cjs +31 -0
- package/dist/internal.d.cts +54 -0
- package/dist/internal.d.mts +54 -0
- package/dist/internal.mjs +3 -0
- package/dist/types-BA-INDkb.d.mts +15 -0
- package/dist/types-Ctyskm8X.d.cts +15 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +3 -0
- package/dist/types.d.mts +3 -0
- package/dist/types.mjs +1 -0
- package/package.json +36 -26
- package/dist/async-i18n-manager/AsyncStorageAdapter.d.ts +0 -19
- package/dist/async-i18n-manager/AsyncStorageI18nManager.d.ts +0 -17
- package/dist/async-i18n-manager/index.d.ts +0 -3
- package/dist/async-i18n-manager/singleton-operations.d.ts +0 -15
- package/dist/helpers/getRequestLocale.d.ts +0 -27
- package/dist/helpers/index.d.ts +0 -3
- package/dist/index.cjs.min.cjs +0 -36
- package/dist/index.cjs.min.cjs.map +0 -1
- package/dist/index.esm.min.mjs +0 -36
- package/dist/index.esm.min.mjs.map +0 -1
- package/dist/internal.cjs.min.cjs +0 -2
- package/dist/internal.cjs.min.cjs.map +0 -1
- package/dist/internal.d.ts +0 -51
- package/dist/internal.esm.min.mjs +0 -2
- package/dist/internal.esm.min.mjs.map +0 -1
- package/dist/setup/index.d.ts +0 -2
- package/dist/setup/initializeGT.d.ts +0 -7
- package/dist/setup/types.d.ts +0 -11
- package/dist/setup/withGT.d.ts +0 -4
- package/dist/translation-functions/index.d.ts +0 -6
- package/dist/translation-functions/types.d.ts +0 -6
- package/dist/types.cjs.min.cjs +0 -2
- package/dist/types.cjs.min.cjs.map +0 -1
- package/dist/types.d.ts +0 -15
- package/dist/types.esm.min.mjs +0 -2
- package/dist/types.esm.min.mjs.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { I18nManagerConstructorParams } from "gt-i18n/internal/types";
|
|
2
|
+
import { I18nManager, I18nManager as I18nManager$1, StorageAdapter, StorageAdapter as StorageAdapter$1, getI18nManager as getI18nManager$1, setI18nManager as setI18nManager$1 } from "gt-i18n/internal";
|
|
3
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
+
import { Translation } from "gt-i18n/types";
|
|
5
|
+
|
|
6
|
+
//#region src/async-i18n-manager/AsyncStorageAdapter.d.ts
|
|
7
|
+
type Store = {
|
|
8
|
+
locale: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* AsyncStorageAdapter implementation that uses AsyncLocalStorage as the storage adapter.
|
|
12
|
+
*/
|
|
13
|
+
declare class AsyncStorageAdapter extends StorageAdapter$1 {
|
|
14
|
+
readonly type: "async-storage-adapter";
|
|
15
|
+
private store;
|
|
16
|
+
constructor(store?: AsyncLocalStorage<Store>);
|
|
17
|
+
run<T>(store: Store, callback: () => T): T;
|
|
18
|
+
getItem(key: keyof Store): string | undefined;
|
|
19
|
+
setItem(key: keyof Store, value: string): void;
|
|
20
|
+
removeItem(key: keyof Store): void;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/async-i18n-manager/AsyncStorageI18nManager.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* I18nManager implementation that uses AsyncStorage as the storage adapter.
|
|
26
|
+
*/
|
|
27
|
+
declare class AsyncStorageI18nManager extends I18nManager$1<AsyncStorageAdapter, string> {
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of AsyncStorageI18nManager.
|
|
30
|
+
* @param {I18nManagerConstructorParams<AsyncStorageAdapter>} config - The configuration for the AsyncStorageI18nManager
|
|
31
|
+
*/
|
|
32
|
+
constructor(config: I18nManagerConstructorParams<AsyncStorageAdapter>);
|
|
33
|
+
/**
|
|
34
|
+
* Create the context for the given locale using the store adapter
|
|
35
|
+
*/
|
|
36
|
+
run<T>(locale: string, fn: () => T): T;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/async-i18n-manager/singleton-operations.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* @description Get the singleton instance of I18nManager.
|
|
42
|
+
* @returns The singleton instance of I18nManager
|
|
43
|
+
*
|
|
44
|
+
* Node only does string translation
|
|
45
|
+
*/
|
|
46
|
+
declare function getI18nManager(): I18nManager$1<AsyncStorageAdapter, string> | I18nManager$1<StorageAdapter$1, string> | I18nManager$1<AsyncStorageAdapter, Translation> | I18nManager$1<StorageAdapter$1, Translation>;
|
|
47
|
+
/**
|
|
48
|
+
* Set the singleton instance of I18nManager
|
|
49
|
+
* @param {I18nManager<AsyncStorageAdapter>} i18nManager - The I18nManager instance
|
|
50
|
+
*/
|
|
51
|
+
declare function setI18nManager(i18nManager: I18nManager$1<AsyncStorageAdapter>): void;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { AsyncStorageAdapter, AsyncStorageI18nManager, I18nManager, StorageAdapter, getI18nManager as asyncStorageGetI18nManager, setI18nManager as asyncStorageSetI18nManager, getI18nManager$1 as getI18nManager, setI18nManager$1 as setI18nManager };
|
|
54
|
+
//# sourceMappingURL=internal.d.cts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { I18nManager, I18nManager as I18nManager$1, StorageAdapter, StorageAdapter as StorageAdapter$1, getI18nManager as getI18nManager$1, setI18nManager as setI18nManager$1 } from "gt-i18n/internal";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
import { I18nManagerConstructorParams } from "gt-i18n/internal/types";
|
|
4
|
+
import { Translation } from "gt-i18n/types";
|
|
5
|
+
|
|
6
|
+
//#region src/async-i18n-manager/AsyncStorageAdapter.d.ts
|
|
7
|
+
type Store = {
|
|
8
|
+
locale: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* AsyncStorageAdapter implementation that uses AsyncLocalStorage as the storage adapter.
|
|
12
|
+
*/
|
|
13
|
+
declare class AsyncStorageAdapter extends StorageAdapter$1 {
|
|
14
|
+
readonly type: "async-storage-adapter";
|
|
15
|
+
private store;
|
|
16
|
+
constructor(store?: AsyncLocalStorage<Store>);
|
|
17
|
+
run<T>(store: Store, callback: () => T): T;
|
|
18
|
+
getItem(key: keyof Store): string | undefined;
|
|
19
|
+
setItem(key: keyof Store, value: string): void;
|
|
20
|
+
removeItem(key: keyof Store): void;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/async-i18n-manager/AsyncStorageI18nManager.d.ts
|
|
24
|
+
/**
|
|
25
|
+
* I18nManager implementation that uses AsyncStorage as the storage adapter.
|
|
26
|
+
*/
|
|
27
|
+
declare class AsyncStorageI18nManager extends I18nManager$1<AsyncStorageAdapter, string> {
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of AsyncStorageI18nManager.
|
|
30
|
+
* @param {I18nManagerConstructorParams<AsyncStorageAdapter>} config - The configuration for the AsyncStorageI18nManager
|
|
31
|
+
*/
|
|
32
|
+
constructor(config: I18nManagerConstructorParams<AsyncStorageAdapter>);
|
|
33
|
+
/**
|
|
34
|
+
* Create the context for the given locale using the store adapter
|
|
35
|
+
*/
|
|
36
|
+
run<T>(locale: string, fn: () => T): T;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/async-i18n-manager/singleton-operations.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* @description Get the singleton instance of I18nManager.
|
|
42
|
+
* @returns The singleton instance of I18nManager
|
|
43
|
+
*
|
|
44
|
+
* Node only does string translation
|
|
45
|
+
*/
|
|
46
|
+
declare function getI18nManager(): I18nManager$1<AsyncStorageAdapter, string> | I18nManager$1<StorageAdapter$1, string> | I18nManager$1<AsyncStorageAdapter, Translation> | I18nManager$1<StorageAdapter$1, Translation>;
|
|
47
|
+
/**
|
|
48
|
+
* Set the singleton instance of I18nManager
|
|
49
|
+
* @param {I18nManager<AsyncStorageAdapter>} i18nManager - The I18nManager instance
|
|
50
|
+
*/
|
|
51
|
+
declare function setI18nManager(i18nManager: I18nManager$1<AsyncStorageAdapter>): void;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { AsyncStorageAdapter, AsyncStorageI18nManager, I18nManager, StorageAdapter, getI18nManager as asyncStorageGetI18nManager, setI18nManager as asyncStorageSetI18nManager, getI18nManager$1 as getI18nManager, setI18nManager$1 as setI18nManager };
|
|
54
|
+
//# sourceMappingURL=internal.d.mts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as setI18nManager, i as getI18nManager, n as AsyncStorageAdapter, r as AsyncStorageI18nManager } from "./AsyncStorageAdapter-D852UaVa.mjs";
|
|
2
|
+
import { I18nManager, StorageAdapter, getI18nManager as getI18nManager$1, setI18nManager as setI18nManager$1 } from "gt-i18n/internal";
|
|
3
|
+
export { AsyncStorageAdapter, AsyncStorageI18nManager, I18nManager, StorageAdapter, getI18nManager as asyncStorageGetI18nManager, setI18nManager as asyncStorageSetI18nManager, getI18nManager$1 as getI18nManager, setI18nManager$1 as setI18nManager };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GTConfig, GTConfig as GTConfig$1, TranslationsLoader, TranslationsLoader as TranslationsLoader$1 } from "gt-i18n/internal/types";
|
|
2
|
+
|
|
3
|
+
//#region src/setup/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for the initializing GT
|
|
6
|
+
* @param {string} params.defaultLocale - The default locale to use
|
|
7
|
+
* @param {string[]} params.locales - The locales to support
|
|
8
|
+
* @param {object} params.loadTranslations - The custom translation loader to use
|
|
9
|
+
*/
|
|
10
|
+
type InitializeGTParams = GTConfig & {
|
|
11
|
+
loadTranslations?: TranslationsLoader;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InitializeGTParams as n, TranslationsLoader$1 as r, GTConfig$1 as t };
|
|
15
|
+
//# sourceMappingURL=types-BA-INDkb.d.mts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GTConfig, GTConfig as GTConfig$1, TranslationsLoader, TranslationsLoader as TranslationsLoader$1 } from "gt-i18n/internal/types";
|
|
2
|
+
|
|
3
|
+
//#region src/setup/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for the initializing GT
|
|
6
|
+
* @param {string} params.defaultLocale - The default locale to use
|
|
7
|
+
* @param {string[]} params.locales - The locales to support
|
|
8
|
+
* @param {object} params.loadTranslations - The custom translation loader to use
|
|
9
|
+
*/
|
|
10
|
+
type InitializeGTParams = GTConfig & {
|
|
11
|
+
loadTranslations?: TranslationsLoader;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InitializeGTParams as n, TranslationsLoader$1 as r, GTConfig$1 as t };
|
|
15
|
+
//# sourceMappingURL=types-Ctyskm8X.d.cts.map
|
package/dist/types.cjs
ADDED
|
File without changes
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as InitializeGTParams, r as TranslationsLoader, t as GTConfig } from "./types-Ctyskm8X.cjs";
|
|
2
|
+
import { DictionaryTranslationOptions, GTFunctionType, InlineTranslationOptions, MFunctionType, RuntimeTranslationOptions, TFunctionType } from "gt-i18n/types";
|
|
3
|
+
export { type DictionaryTranslationOptions, GTConfig, type GTFunctionType, InitializeGTParams, type InlineTranslationOptions, type MFunctionType, type RuntimeTranslationOptions, type TFunctionType, TranslationsLoader };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as InitializeGTParams, r as TranslationsLoader, t as GTConfig } from "./types-BA-INDkb.mjs";
|
|
2
|
+
import { DictionaryTranslationOptions, GTFunctionType, InlineTranslationOptions, MFunctionType, RuntimeTranslationOptions, TFunctionType } from "gt-i18n/types";
|
|
3
|
+
export { type DictionaryTranslationOptions, GTConfig, type GTFunctionType, InitializeGTParams, type InlineTranslationOptions, type MFunctionType, type RuntimeTranslationOptions, type TFunctionType, TranslationsLoader };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-node",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "Node.js utilities for General Translation",
|
|
5
|
-
"main": "dist/index.cjs
|
|
6
|
-
"module": "dist/index.
|
|
7
|
-
"types": "dist/index.d.
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.cts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"CHANGELOG.md"
|
|
11
11
|
],
|
|
12
|
+
"sideEffects": false,
|
|
12
13
|
"engines": {
|
|
13
14
|
"node": ">=18.0.0"
|
|
14
15
|
},
|
|
@@ -35,47 +36,56 @@
|
|
|
35
36
|
},
|
|
36
37
|
"homepage": "https://generaltranslation.com/",
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@rollup/plugin-commonjs": "^28.0.1",
|
|
39
|
-
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
40
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
41
|
-
"@rollup/plugin-typescript": "^12.1.1",
|
|
42
39
|
"@types/node": "^20.14.9",
|
|
43
|
-
"
|
|
44
|
-
"rollup-plugin-dts": "^6.1.1",
|
|
45
|
-
"tslib": "^2.8.0",
|
|
40
|
+
"tsdown": "^0.21.10",
|
|
46
41
|
"typescript": "^5.6.2"
|
|
47
42
|
},
|
|
48
43
|
"typescript": {
|
|
49
|
-
"definition": "dist/index.d.
|
|
44
|
+
"definition": "dist/index.d.cts"
|
|
50
45
|
},
|
|
51
46
|
"dependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
47
|
+
"gt-i18n": "0.8.5",
|
|
48
|
+
"generaltranslation": "8.2.7"
|
|
54
49
|
},
|
|
55
50
|
"exports": {
|
|
56
51
|
".": {
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
"require": {
|
|
53
|
+
"types": "./dist/index.d.cts",
|
|
54
|
+
"default": "./dist/index.cjs"
|
|
55
|
+
},
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/index.d.mts",
|
|
58
|
+
"default": "./dist/index.mjs"
|
|
59
|
+
}
|
|
60
60
|
},
|
|
61
61
|
"./types": {
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
"require": {
|
|
63
|
+
"types": "./dist/types.d.cts",
|
|
64
|
+
"default": "./dist/types.cjs"
|
|
65
|
+
},
|
|
66
|
+
"import": {
|
|
67
|
+
"types": "./dist/types.d.mts",
|
|
68
|
+
"default": "./dist/types.mjs"
|
|
69
|
+
}
|
|
65
70
|
},
|
|
66
71
|
"./internal": {
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
"require": {
|
|
73
|
+
"types": "./dist/internal.d.cts",
|
|
74
|
+
"default": "./dist/internal.cjs"
|
|
75
|
+
},
|
|
76
|
+
"import": {
|
|
77
|
+
"types": "./dist/internal.d.mts",
|
|
78
|
+
"default": "./dist/internal.mjs"
|
|
79
|
+
}
|
|
70
80
|
}
|
|
71
81
|
},
|
|
72
82
|
"typesVersions": {
|
|
73
83
|
"*": {
|
|
74
84
|
"types": [
|
|
75
|
-
"./dist/types.d.
|
|
85
|
+
"./dist/types.d.cts"
|
|
76
86
|
],
|
|
77
87
|
"internal": [
|
|
78
|
-
"./dist/internal.d.
|
|
88
|
+
"./dist/internal.d.cts"
|
|
79
89
|
]
|
|
80
90
|
}
|
|
81
91
|
},
|
|
@@ -93,7 +103,7 @@
|
|
|
93
103
|
"scripts": {
|
|
94
104
|
"build:release": "pnpm run build:clean",
|
|
95
105
|
"build:clean": "sh ../../scripts/clean.sh && pnpm run build",
|
|
96
|
-
"build": "
|
|
106
|
+
"build": "tsdown",
|
|
97
107
|
"lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
|
|
98
108
|
"lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
|
|
99
109
|
"test": "vitest run --config=./vitest.config.ts",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { StorageAdapter } from 'gt-i18n/internal';
|
|
2
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
-
type Store = {
|
|
4
|
-
locale: string;
|
|
5
|
-
};
|
|
6
|
-
declare const ASYNC_STORAGE_ADAPTER_TYPE: "async-storage-adapter";
|
|
7
|
-
/**
|
|
8
|
-
* AsyncStorageAdapter implementation that uses AsyncLocalStorage as the storage adapter.
|
|
9
|
-
*/
|
|
10
|
-
declare class AsyncStorageAdapter extends StorageAdapter {
|
|
11
|
-
readonly type: "async-storage-adapter";
|
|
12
|
-
private store;
|
|
13
|
-
constructor(store?: AsyncLocalStorage<Store>);
|
|
14
|
-
run<T>(store: Store, callback: () => T): T;
|
|
15
|
-
getItem(key: keyof Store): string | undefined;
|
|
16
|
-
setItem(key: keyof Store, value: string): void;
|
|
17
|
-
removeItem(key: keyof Store): void;
|
|
18
|
-
}
|
|
19
|
-
export { AsyncStorageAdapter, ASYNC_STORAGE_ADAPTER_TYPE };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { I18nManager } from 'gt-i18n/internal';
|
|
2
|
-
import { AsyncStorageAdapter } from './AsyncStorageAdapter';
|
|
3
|
-
import { I18nManagerConstructorParams } from 'gt-i18n/internal/types';
|
|
4
|
-
/**
|
|
5
|
-
* I18nManager implementation that uses AsyncStorage as the storage adapter.
|
|
6
|
-
*/
|
|
7
|
-
export declare class AsyncStorageI18nManager extends I18nManager<AsyncStorageAdapter, string> {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of AsyncStorageI18nManager.
|
|
10
|
-
* @param {I18nManagerConstructorParams<AsyncStorageAdapter>} config - The configuration for the AsyncStorageI18nManager
|
|
11
|
-
*/
|
|
12
|
-
constructor(config: I18nManagerConstructorParams<AsyncStorageAdapter>);
|
|
13
|
-
/**
|
|
14
|
-
* Create the context for the given locale using the store adapter
|
|
15
|
-
*/
|
|
16
|
-
run<T>(locale: string, fn: () => T): T;
|
|
17
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { I18nManager, StorageAdapter } from 'gt-i18n/internal';
|
|
2
|
-
import { AsyncStorageAdapter } from './AsyncStorageAdapter';
|
|
3
|
-
import { Translation } from 'gt-i18n/types';
|
|
4
|
-
/**
|
|
5
|
-
* @description Get the singleton instance of I18nManager.
|
|
6
|
-
* @returns The singleton instance of I18nManager
|
|
7
|
-
*
|
|
8
|
-
* Node only does string translation
|
|
9
|
-
*/
|
|
10
|
-
export declare function getI18nManager(): I18nManager<AsyncStorageAdapter, string> | I18nManager<StorageAdapter, string> | I18nManager<AsyncStorageAdapter, Translation> | I18nManager<StorageAdapter, Translation>;
|
|
11
|
-
/**
|
|
12
|
-
* Set the singleton instance of I18nManager
|
|
13
|
-
* @param {I18nManager<AsyncStorageAdapter>} i18nManager - The I18nManager instance
|
|
14
|
-
*/
|
|
15
|
-
export declare function setI18nManager(i18nManager: I18nManager<AsyncStorageAdapter>): void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A request object like interface
|
|
3
|
-
* @interface RequestLike
|
|
4
|
-
* @property {Record<string, string | string[] | undefined>} headers - The request headers
|
|
5
|
-
*/
|
|
6
|
-
interface RequestLike {
|
|
7
|
-
headers: Record<string, string | string[] | undefined>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Resolve the preferred locale from the request Accept-Language header, fallback to the default locale if no match is found
|
|
11
|
-
* @param request - The request object
|
|
12
|
-
* @returns The preferred locale
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const locale = getRequestLocale({ headers: { 'accept-language': 'fr-FR,fr;q=0.9,en;q=0.8' } });
|
|
16
|
-
* console.log(locale); // 'fr'
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* app.get('/', (req, res) => {
|
|
20
|
-
* const locale = getRequestLocale(req);
|
|
21
|
-
* withGT(locale, () => {
|
|
22
|
-
* res.send(`Locale: ${locale}`);
|
|
23
|
-
* });
|
|
24
|
-
* });
|
|
25
|
-
*/
|
|
26
|
-
export declare function getRequestLocale(request: RequestLike): string;
|
|
27
|
-
export {};
|
package/dist/helpers/index.d.ts
DELETED