gt-node 0.6.1 → 0.6.3
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 +14 -0
- package/dist/helpers/getRequestLocale.d.ts +27 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/index.cjs.min.cjs +5 -5
- package/dist/index.cjs.min.cjs.map +1 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.esm.min.mjs +5 -5
- package/dist/index.esm.min.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# gt-node
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1225](https://github.com/generaltranslation/gt/pull/1225) [`f769750`](https://github.com/generaltranslation/gt/commit/f769750d813293c5978ad975f7cc338f836e0aa6) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - fix: utility function for extracting a request locale
|
|
8
|
+
|
|
9
|
+
## 0.6.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`02ef6fc`](https://github.com/generaltranslation/gt/commit/02ef6fcbd979247b9157e768e5a07b3285aaa6ec)]:
|
|
14
|
+
- generaltranslation@8.2.5
|
|
15
|
+
- gt-i18n@0.8.3
|
|
16
|
+
|
|
3
17
|
## 0.6.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -0,0 +1,27 @@
|
|
|
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
CHANGED