@koine/next 2.0.0-beta.27 → 2.0.0-beta.28
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/12/DynamicNamespaces.d.ts +1 -1
- package/12/T.d.ts +2 -1
- package/12/createUseLocale.d.ts +2 -0
- package/12/createUseLocale.js +7 -0
- package/12/createUseTo.d.ts +3 -0
- package/12/createUseTo.js +22 -0
- package/12/getT.d.ts +1 -1
- package/12/translationAsOptions.d.ts +1 -1
- package/12/types.d.ts +0 -3
- package/12/types.js +1 -2
- package/12/useT.d.ts +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +10 -4
- package/typings.d.ts +0 -39
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { TranslateNamespace } from "@koine/i18n";
|
|
1
2
|
import type { DynamicNamespacesProps as BaseDynamicNamespacesProps } from "next-translate";
|
|
2
3
|
import BaseDynamicNamespaces from "next-translate/DynamicNamespaces";
|
|
3
|
-
import type { TranslateNamespace } from "./types-i18n.js";
|
|
4
4
|
export type DynamicNamespacesProps = Omit<BaseDynamicNamespacesProps, "namespaces"> & {
|
|
5
5
|
namespaces: TranslateNamespace[];
|
|
6
6
|
};
|
package/12/T.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TranslateNamespace, TranslationsAllPaths, TranslationsPaths } from "@koine/i18n";
|
|
1
3
|
import type { TransProps } from "next-translate";
|
|
2
|
-
import type { TranslateNamespace, TranslationsAllPaths, TranslationsPaths } from "./types-i18n.js";
|
|
3
4
|
export type TProps<TNamespace extends TranslateNamespace | undefined = undefined> = (Omit<TransProps, "i18nKey" | "ns"> & {
|
|
4
5
|
i18nKey: TranslationsAllPaths;
|
|
5
6
|
}) | (Omit<TransProps, "i18nKey" | "ns"> & {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ToRoute, type ToRouteDynamic, type ToRouteDynamicParams, type ToRouteStatic } from "@koine/i18n";
|
|
2
|
+
export declare const createUseTo: <TLocales extends string[] | readonly string[]>(useLocaleHook: () => TLocales[number], _locales: TLocales, defaultLocale: TLocales[number], hideDefaultLocaleInUrl?: boolean) => () => <TRoute extends ToRoute>(...args: TRoute extends ToRouteDynamic ? [routeId: TRoute, routeParams: ToRouteDynamicParams<TRoute>] : TRoute extends ToRouteStatic ? [routeId: ToRouteStatic] : never) => string;
|
|
3
|
+
export default createUseTo;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { __read } from "tslib";
|
|
3
|
+
import { createTo, } from "@koine/i18n";
|
|
4
|
+
import { useT } from "./useT.js";
|
|
5
|
+
export var createUseTo = function (useLocaleHook, _locales, defaultLocale, hideDefaultLocaleInUrl) {
|
|
6
|
+
return function () {
|
|
7
|
+
var t = useT("~");
|
|
8
|
+
var locale = useLocaleHook();
|
|
9
|
+
var _to = createTo(_locales, defaultLocale, hideDefaultLocaleInUrl);
|
|
10
|
+
return function () {
|
|
11
|
+
var args = [];
|
|
12
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
+
args[_i] = arguments[_i];
|
|
14
|
+
}
|
|
15
|
+
var _a = __read(args, 2), routeId = _a[0], routeParams = _a[1];
|
|
16
|
+
return routeParams
|
|
17
|
+
? _to(locale, t, routeId, routeParams)
|
|
18
|
+
: _to(locale, t, routeId);
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default createUseTo;
|
package/12/getT.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Translate, TranslateNamespace } from "
|
|
1
|
+
import type { Translate, TranslateNamespace } from "@koine/i18n";
|
|
2
2
|
export type GetT = <TNamespace extends TranslateNamespace | undefined = undefined>(locale?: string, namespace?: TNamespace) => Promise<Translate<TNamespace>>;
|
|
3
3
|
export declare const getT: GetT;
|
|
4
4
|
export default getT;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type { TranslateLoose } from "@koine/i18n";
|
|
1
2
|
import type { Option } from "@koine/react/types";
|
|
2
|
-
import type { TranslateLoose } from "./types-i18n.js";
|
|
3
3
|
export declare function translationAsOptions(t: TranslateLoose, i18nKey: string): Option[];
|
|
4
4
|
export default translationAsOptions;
|
package/12/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export * from "./types-i18n.js";
|
|
2
|
-
export * from "./types-seo.js";
|
|
3
1
|
export type { TProps } from "./T.js";
|
|
4
2
|
export type { GetT } from "./getT.js";
|
|
5
3
|
export type { DynamicNamespacesProps } from "./DynamicNamespaces.js";
|
|
6
4
|
export type { SeoDefaultsProps } from "./SeoDefaults.js";
|
|
7
|
-
export type { ToTranslate, ToStaticRoute, ToDynamicRoute, ToArgs } from "./to.js";
|
package/12/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./types-seo.js";
|
|
1
|
+
export {};
|
package/12/useT.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TranslateDefault, TranslateNamespace, TranslateNamespaced } from "
|
|
1
|
+
import type { TranslateDefault, TranslateNamespace, TranslateNamespaced } from "@koine/i18n";
|
|
2
2
|
export declare function useT(): TranslateDefault;
|
|
3
3
|
export declare function useT<TNamespace extends TranslateNamespace>(namespace: TNamespace): TranslateNamespaced<TNamespace>;
|
|
4
4
|
export default useT;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@koine/next",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@koine/browser": "2.0.0-beta.
|
|
6
|
-
"@koine/react": "2.0.0-beta.
|
|
7
|
-
"@koine/utils": "2.0.0-beta.
|
|
5
|
+
"@koine/browser": "2.0.0-beta.28",
|
|
6
|
+
"@koine/react": "2.0.0-beta.28",
|
|
7
|
+
"@koine/utils": "2.0.0-beta.28"
|
|
8
8
|
},
|
|
9
9
|
"peerDependenciesMeta": {
|
|
10
10
|
"@kuus/yup": {
|
|
@@ -95,6 +95,12 @@
|
|
|
95
95
|
"./12/app/sc": {
|
|
96
96
|
"import": "./12/app/sc/index.js"
|
|
97
97
|
},
|
|
98
|
+
"./12/createUseLocale": {
|
|
99
|
+
"import": "./12/createUseLocale.js"
|
|
100
|
+
},
|
|
101
|
+
"./12/createUseTo": {
|
|
102
|
+
"import": "./12/createUseTo.js"
|
|
103
|
+
},
|
|
98
104
|
"./12/document/Document": {
|
|
99
105
|
"import": "./12/document/Document.js"
|
|
100
106
|
},
|
|
@@ -172,5 +178,5 @@
|
|
|
172
178
|
}
|
|
173
179
|
},
|
|
174
180
|
"peerDependencies": {},
|
|
175
|
-
"version": "2.0.0-beta.
|
|
181
|
+
"version": "2.0.0-beta.28"
|
|
176
182
|
}
|
package/typings.d.ts
CHANGED
|
@@ -11,15 +11,6 @@ declare module "*.svg" {
|
|
|
11
11
|
export default content;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Extend NodeJS `process.env` with variables used by @koine
|
|
16
|
-
*/
|
|
17
|
-
declare namespace NodeJS {
|
|
18
|
-
interface ProcessEnv {
|
|
19
|
-
NEXT_PUBLIC_APP_URL: string;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
14
|
/**
|
|
24
15
|
* Types specifically related to `@koine/next` exposed on the global unique
|
|
25
16
|
* namespace `Koine`. Most of the types here should be prefixed by `Next`, e.g.
|
|
@@ -30,36 +21,6 @@ declare namespace Koine {
|
|
|
30
21
|
* Default SEO data structure expected by the `<Seo>` component's prop `seo`
|
|
31
22
|
*/
|
|
32
23
|
type NextSeo = import("./12/types-seo").SeoData;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Translations dictionary extracted from JSON files.
|
|
36
|
-
* You need to augment this type with something like:
|
|
37
|
-
*
|
|
38
|
-
* ```ts
|
|
39
|
-
* declare namespace Koine {
|
|
40
|
-
* interface Translations {
|
|
41
|
-
* "~": typeof import("./locales/en/~.json");
|
|
42
|
-
* "_": typeof import("./locales/en/_.json");
|
|
43
|
-
* "$team": typeof import("./locales/en/$team.json");
|
|
44
|
-
* "home": typeof import("./locales/en/home.json");
|
|
45
|
-
* "Header": typeof import("./locales/en/Header.json");
|
|
46
|
-
* }
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* Best to follow a convention to name the files which become the namespaces:
|
|
51
|
-
*
|
|
52
|
-
* - `~`: for app wide **urls** translated definitions
|
|
53
|
-
* - `_`: for app wide **common** translations
|
|
54
|
-
* - `${data}`: dollar prefix for static **data** like arrays, objects, .etc
|
|
55
|
-
* - `{route-name}`: lower cased for **route** specific data
|
|
56
|
-
* - `{ComponentName}`: pascal cased for **components** specific data
|
|
57
|
-
*
|
|
58
|
-
* This works through using [type augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation)
|
|
59
|
-
* and [merging interfaces](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces).
|
|
60
|
-
*/
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
62
|
-
interface Translations {}
|
|
63
24
|
}
|
|
64
25
|
|
|
65
26
|
/**
|