@hyvor/design 0.0.60 → 0.0.61-alpha
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/components/Internationalization/T.svelte +9 -9
- package/dist/components/Internationalization/T.svelte.d.ts +8 -8
- package/dist/components/Internationalization/i18n.d.ts +3 -3
- package/dist/components/Internationalization/t.d.ts +2 -1
- package/dist/components/Internationalization/types.d.ts +6 -8
- package/dist/components/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
<script generics="StringsT extends
|
|
2
|
-
import {
|
|
1
|
+
<script generics="StringsT extends I18nStrings">import {} from "./types.js";
|
|
2
|
+
import {
|
|
3
|
+
getContext,
|
|
4
|
+
onMount,
|
|
5
|
+
tick,
|
|
6
|
+
afterUpdate
|
|
7
|
+
} from "svelte";
|
|
3
8
|
import { getStringByKey, InternationalizationService } from "./i18n.js";
|
|
4
9
|
import { IntlMessageFormat } from "intl-messageformat";
|
|
5
10
|
import { browser } from "$app/environment";
|
|
@@ -69,12 +74,7 @@ const locale = i18n.locale;
|
|
|
69
74
|
const strings = i18n.strings;
|
|
70
75
|
let message = getMessage(getParamsForBackend());
|
|
71
76
|
function getMessage(processedParams) {
|
|
72
|
-
return getMessageBase(
|
|
73
|
-
key,
|
|
74
|
-
processedParams,
|
|
75
|
-
$strings,
|
|
76
|
-
$locale
|
|
77
|
-
);
|
|
77
|
+
return getMessageBase(key, processedParams, $strings, $locale);
|
|
78
78
|
}
|
|
79
79
|
function bindComponents() {
|
|
80
80
|
for (let [id, binding] of componentBindings) {
|
|
@@ -111,4 +111,4 @@ onMount(async () => {
|
|
|
111
111
|
});
|
|
112
112
|
</script>
|
|
113
113
|
|
|
114
|
-
{@html message}
|
|
114
|
+
{@html message}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import { type
|
|
2
|
+
import { type ToDotPaths, type I18nStrings } from "./types.js";
|
|
3
3
|
import { type ComponentType } from "svelte";
|
|
4
|
-
import { type PrimitiveType } from
|
|
5
|
-
declare class __sveltets_Render<StringsT extends
|
|
4
|
+
import { type PrimitiveType } from "intl-messageformat";
|
|
5
|
+
declare class __sveltets_Render<StringsT extends I18nStrings> {
|
|
6
6
|
props(): {
|
|
7
|
-
key:
|
|
7
|
+
key: ToDotPaths<StringsT>;
|
|
8
8
|
params?: Record<string, PrimitiveType | {
|
|
9
9
|
element?: string | undefined;
|
|
10
10
|
component?: ComponentType | undefined;
|
|
@@ -16,9 +16,9 @@ declare class __sveltets_Render<StringsT extends i18nStrings> {
|
|
|
16
16
|
};
|
|
17
17
|
slots(): {};
|
|
18
18
|
}
|
|
19
|
-
export type TProps<StringsT extends
|
|
20
|
-
export type TEvents<StringsT extends
|
|
21
|
-
export type TSlots<StringsT extends
|
|
22
|
-
export default class T<StringsT extends
|
|
19
|
+
export type TProps<StringsT extends I18nStrings> = ReturnType<__sveltets_Render<StringsT>['props']>;
|
|
20
|
+
export type TEvents<StringsT extends I18nStrings> = ReturnType<__sveltets_Render<StringsT>['events']>;
|
|
21
|
+
export type TSlots<StringsT extends I18nStrings> = ReturnType<__sveltets_Render<StringsT>['slots']>;
|
|
22
|
+
export default class T<StringsT extends I18nStrings> extends SvelteComponent<TProps<StringsT>, TEvents<StringsT>, TSlots<StringsT>> {
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { PrimitiveType } from "intl-messageformat";
|
|
3
3
|
import { type Readable, type Writable } from "svelte/store";
|
|
4
4
|
import T from "./T.svelte";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ToDotPaths, I18nStrings } from "./types.js";
|
|
6
6
|
export type i18nLoaderType = () => Promise<any>;
|
|
7
7
|
interface LanguageBase {
|
|
8
8
|
name: string;
|
|
@@ -18,7 +18,7 @@ interface LanguageWithLoader extends LanguageBase {
|
|
|
18
18
|
loader: i18nLoaderType;
|
|
19
19
|
}
|
|
20
20
|
export type Language = LanguageWithStrings | LanguageWithLoader;
|
|
21
|
-
export declare class InternationalizationService<StringsT extends
|
|
21
|
+
export declare class InternationalizationService<StringsT extends I18nStrings = I18nStrings> {
|
|
22
22
|
languages: LanguageWithLoader[];
|
|
23
23
|
locale: Writable<string>;
|
|
24
24
|
localeLanguage: Readable<LanguageWithLoader>;
|
|
@@ -31,7 +31,7 @@ export declare class InternationalizationService<StringsT extends i18nStrings =
|
|
|
31
31
|
register(language: Language): void;
|
|
32
32
|
found(code: string): boolean;
|
|
33
33
|
languageByCode(code: string): LanguageWithLoader | undefined;
|
|
34
|
-
t(key:
|
|
34
|
+
t(key: ToDotPaths<StringsT>, params?: Record<string, PrimitiveType>): string;
|
|
35
35
|
T: typeof T<StringsT>;
|
|
36
36
|
}
|
|
37
37
|
export declare function getStringByKey(messages: Record<string, any>, key: string): string | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type PrimitiveType } from "intl-messageformat";
|
|
2
2
|
import { type InternationalizationService } from "./i18n.js";
|
|
3
|
+
import type { I18nStrings, ToDotPaths } from "./types.js";
|
|
3
4
|
type ParamValue = PrimitiveType | ((chunks: string | string[]) => string);
|
|
4
5
|
type ParamsType = Record<string, ParamValue>;
|
|
5
6
|
export declare function getMessage(key: string, params: ParamsType, $strings: Record<string, any>, $locale: string): string;
|
|
6
7
|
export type TParams = Record<string, PrimitiveType>;
|
|
7
|
-
export declare function t(key:
|
|
8
|
+
export declare function t<T extends ToDotPaths<I18nStrings>>(key: T, params?: Record<string, PrimitiveType>, i18n?: InternationalizationService | null): string;
|
|
8
9
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export type
|
|
2
|
-
[key: string]: string |
|
|
1
|
+
export type I18nStrings = {
|
|
2
|
+
[key: string]: string | I18nStrings;
|
|
3
3
|
};
|
|
4
|
-
type
|
|
5
|
-
[K in
|
|
6
|
-
}[
|
|
7
|
-
type
|
|
8
|
-
export type DotNotation<T extends i18nStrings> = Join<PathsToStringProps<T>, ".">;
|
|
9
|
-
export {};
|
|
4
|
+
export type ToDotPaths<T> = T extends object ? {
|
|
5
|
+
[K in keyof T]: `${Exclude<K, symbol>}${"" | `.${ToDotPaths<T[K]>}`}`;
|
|
6
|
+
}[keyof T] : never;
|
|
7
|
+
export type FromDotPath<T, K extends string> = K extends keyof T ? T[K] : K extends `${infer K0}.${infer KR}` ? K0 extends keyof T ? FromDotPath<T[K0], KR> : never : never;
|
|
@@ -44,7 +44,7 @@ export { clickOutside } from './directives/clickOutside.js';
|
|
|
44
44
|
export { default as InternationalizationProvider } from './Internationalization/InternationalizationProvider.svelte';
|
|
45
45
|
export { default as LanguageToggle } from './Internationalization/LanguageToggle.svelte';
|
|
46
46
|
export { type Language as InternationalizationLanguage, InternationalizationService } from './Internationalization/i18n.js';
|
|
47
|
-
export { type i18nStrings } from './Internationalization/types.js';
|
|
47
|
+
export { type I18nStrings as i18nStrings } from './Internationalization/types.js';
|
|
48
48
|
/**
|
|
49
49
|
* @deprecated
|
|
50
50
|
*/
|