Skip to content

Commit

Permalink
Improve exported translation types
Browse files Browse the repository at this point in the history
  • Loading branch information
f-elix committed May 16, 2024
1 parent 2c05468 commit 4b673e3
Show file tree
Hide file tree
Showing 41 changed files with 143 additions and 45 deletions.
7 changes: 7 additions & 0 deletions packages/components/html-elements/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @288-toolkit/html-elements

## 3.0.16

### Patch Changes

- Updated dependencies
- @288-toolkit/format@4.1.2

## 3.0.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/components/html-elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/html-elements",
"version": "3.0.15",
"version": "3.0.16",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
9 changes: 9 additions & 0 deletions packages/components/pagination/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @288-toolkit/pagination

## 3.2.2

### Patch Changes

- Improve exported types
- Updated dependencies
- @288-toolkit/forms@4.3.2
- @288-toolkit/i18n@9.0.1

## 3.2.1

### Patch Changes
Expand Down
8 changes: 7 additions & 1 deletion packages/components/pagination/dist/translations/loader.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export declare const pagination: Translation;
export declare const pagination: {
readonly key: "pagination";
readonly loaders: {
readonly en: () => Promise<typeof import("./en.js")>;
readonly fr: () => Promise<typeof import("./fr.js")>;
};
};
2 changes: 1 addition & 1 deletion packages/components/pagination/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/pagination",
"version": "3.2.1",
"version": "3.2.2",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
3 changes: 1 addition & 2 deletions packages/components/pagination/src/translations/loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Translation } from '@288-toolkit/i18n/types';
import { key } from './index.js';

export const pagination = {
Expand All @@ -7,4 +6,4 @@ export const pagination = {
en: () => import('./en.js'),
fr: () => import('./fr.js')
}
} as const satisfies Translation;
} as const;
8 changes: 8 additions & 0 deletions packages/components/slideshow/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @288-toolkit/slideshow

## 3.2.2

### Patch Changes

- Improve exported types
- Updated dependencies
- @288-toolkit/i18n@9.0.1

## 3.2.1

### Patch Changes
Expand Down
8 changes: 7 additions & 1 deletion packages/components/slideshow/dist/translations/loader.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export declare const slideshow: Translation;
export declare const slideshow: {
readonly key: "slideshow";
readonly loaders: {
readonly en: () => Promise<typeof import("./en.js")>;
readonly fr: () => Promise<typeof import("./fr.js")>;
};
};
2 changes: 1 addition & 1 deletion packages/components/slideshow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/slideshow",
"version": "3.2.1",
"version": "3.2.2",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
3 changes: 1 addition & 2 deletions packages/components/slideshow/src/translations/loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Translation } from '@288-toolkit/i18n/types';
import { key } from './index.js';

export const slideshow = {
Expand All @@ -7,4 +6,4 @@ export const slideshow = {
en: () => import('./en.js'),
fr: () => import('./fr.js')
}
} as const satisfies Translation;
} as const;
9 changes: 9 additions & 0 deletions packages/components/video-embed/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @288-toolkit/video-embed

## 3.2.2

### Patch Changes

- Improve exported types
- Updated dependencies
- @288-toolkit/i18n@9.0.1
- @288-toolkit/html-elements@3.0.16

## 3.2.1

### Patch Changes
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export declare const videoEmbed: Translation;
export declare const videoEmbed: {
readonly key: "video-embed";
readonly loaders: {
readonly en: () => Promise<typeof import("./en.js")>;
readonly fr: () => Promise<typeof import("./fr.js")>;
};
};
2 changes: 1 addition & 1 deletion packages/components/video-embed/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/video-embed",
"version": "3.2.1",
"version": "3.2.2",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Translation } from '@288-toolkit/i18n/types';
import { key } from './index.js';

export const videoEmbed = {
Expand All @@ -7,4 +6,4 @@ export const videoEmbed = {
en: () => import('./en.js'),
fr: () => import('./fr.js')
}
} as const satisfies Translation;
} as const;
7 changes: 7 additions & 0 deletions packages/dates/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @288-toolkit/dates

## 4.0.15

### Patch Changes

- Updated dependencies
- @288-toolkit/format@4.1.2

## 4.0.14

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/dates/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/dates",
"version": "4.0.14",
"version": "4.0.15",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
8 changes: 8 additions & 0 deletions packages/format/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @288-toolkit/format

## 4.1.2

### Patch Changes

- Improve exported types
- Updated dependencies
- @288-toolkit/i18n@9.0.1

## 4.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/format/dist/date.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* turns on a single option, then call `format()` with the date passed to the function.
* Those function are also available for imports.
*/
import type { Locale } from '@288-toolkit/i18n/types';
import type { Locale } from '@288-toolkit/i18n';
import type { Maybe, MaybeUndefined } from '@288-toolkit/types';
import type { TimeZone } from '@288-toolkit/types/timezones';
import { USER_LOCALE } from './userLocale.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/format/dist/price.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Locale } from '@288-toolkit/i18n/types';
import type { Locale } from '@288-toolkit/i18n';
import { USER_LOCALE } from './userLocale.js';
export type Price = number;
export type FormatPriceLocale = Locale | USER_LOCALE;
Expand Down
2 changes: 1 addition & 1 deletion packages/format/dist/relativeTime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* 3- `timeAgo(date)`: formats the date relative to now, using the default options, unit and locale.
* This is probably the most common use case, so it's provided as a convenience.
*/
import type { Locale } from '@288-toolkit/i18n/types';
import type { Locale } from '@288-toolkit/i18n';
import type { Maybe } from '@288-toolkit/types';
import { USER_LOCALE } from './userLocale.js';
type RelativeTimeLocale = USER_LOCALE | Maybe<Locale>;
Expand Down
24 changes: 21 additions & 3 deletions packages/format/dist/translations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
export declare const duration: Translation;
export declare const filesize: Translation;
export declare const relativeTime: Translation;
export declare const duration: {
readonly key: "duration";
readonly loaders: {
readonly en: () => Promise<typeof import("./duration/en.js")>;
readonly fr: () => Promise<typeof import("./duration/fr.js")>;
};
};
export declare const filesize: {
readonly key: "filesize";
readonly loaders: {
readonly en: () => Promise<typeof import("./filesize/en.js")>;
readonly fr: () => Promise<typeof import("./filesize/fr.js")>;
};
};
export declare const relativeTime: {
readonly key: "relativeTime";
readonly loaders: {
readonly en: () => Promise<typeof import("./relativeTime/en.js")>;
readonly fr: () => Promise<typeof import("./relativeTime/fr.js")>;
};
};
2 changes: 1 addition & 1 deletion packages/format/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/format",
"version": "4.1.1",
"version": "4.1.2",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/lib/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Those function are also available for imports.
*/

import type { Locale } from '@288-toolkit/i18n/types';
import type { Locale } from '@288-toolkit/i18n';
import type { Maybe, MaybeUndefined } from '@288-toolkit/types';
import type { TimeZone } from '@288-toolkit/types/timezones';
import { DEV } from 'esm-env';
Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/lib/price.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Locale } from '@288-toolkit/i18n/types';
import type { Locale } from '@288-toolkit/i18n';
import { DEV } from 'esm-env';
import { USER_LOCALE } from './userLocale.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/format/src/lib/relativeTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* This is probably the most common use case, so it's provided as a convenience.
*/

import type { Locale } from '@288-toolkit/i18n/types';
import type { Locale } from '@288-toolkit/i18n';
import type { Maybe } from '@288-toolkit/types';
import { DEV } from 'esm-env';
import { t } from './translations/relativeTime/index.js';
Expand Down
7 changes: 3 additions & 4 deletions packages/format/src/lib/translations/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Translation } from '@288-toolkit/i18n/types';
import { key as key_duration } from './duration/index.js';
import { key as key_filesize } from './filesize/index.js';
import { key as key_relativeTime } from './relativeTime/index.js';
Expand All @@ -9,20 +8,20 @@ export const duration = {
en: () => import('./duration/en.js'),
fr: () => import('./duration/fr.js')
}
} as const satisfies Translation;
} as const;

export const filesize = {
key: key_filesize,
loaders: {
en: () => import('./filesize/en.js'),
fr: () => import('./filesize/fr.js')
}
} as const satisfies Translation;
} as const;

export const relativeTime = {
key: key_relativeTime,
loaders: {
en: () => import('./relativeTime/en.js'),
fr: () => import('./relativeTime/fr.js')
}
} as const satisfies Translation;
} as const;
8 changes: 8 additions & 0 deletions packages/forms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @288-toolkit/forms

## 4.3.2

### Patch Changes

- Improve exported types
- Updated dependencies
- @288-toolkit/i18n@9.0.1

## 4.3.1

### Patch Changes
Expand Down
8 changes: 7 additions & 1 deletion packages/forms/dist/translations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export declare const newsletterForm: Translation;
export declare const newsletterForm: {
readonly key: "newsletter-form";
readonly loaders: {
readonly en: () => Promise<typeof import("./newsletter-form/en.js")>;
readonly fr: () => Promise<typeof import("./newsletter-form/fr.js")>;
};
};
2 changes: 1 addition & 1 deletion packages/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@288-toolkit/forms",
"version": "4.3.1",
"version": "4.3.2",
"author": "DeuxHuitHuit",
"license": "MIT",
"type": "module",
Expand Down
3 changes: 1 addition & 2 deletions packages/forms/src/translations/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Translation } from '@288-toolkit/i18n/types';
import { key as key_newsletter } from './newsletter-form/index.js';

export const newsletterForm = {
Expand All @@ -7,4 +6,4 @@ export const newsletterForm = {
en: () => import('./newsletter-form/en.js'),
fr: () => import('./newsletter-form/fr.js')
}
} as const satisfies Translation;
} as const;
6 changes: 6 additions & 0 deletions packages/i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @288-toolkit/i18n

## 9.0.1

### Patch Changes

- Improve exported types

## 9.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Finally, to get type safety for the locals, you need to extend the `App.Locals`
In `app.d.ts`:

```ts
import type { LangInfo } from '@288-toolkit/i18n/types';
import type { LangInfo } from '@288-toolkit/i18n';

declare global {
namespace App {
Expand Down Expand Up @@ -371,7 +371,7 @@ the same as the client side version.

```ts
import { createServerTranslate } from '@288-toolkit/i18n/server';
import type { Translation } from '@288-toolkit/i18n/types';
import type { Translation } from '@288-toolkit/i18n';

const translationObject: Translation = {
key: 'global',
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/dist/createTranslate.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { AnonymousObject, PropertyStringPath } from '@288-toolkit/types';
import type { DataType, TranslateParams, Translation } from './types';
import type { DataType, TranslateParams, Translation } from './types/index.js';
export declare const createTranslate: <TTranslationsObject extends AnonymousObject>(translationKey: Translation['key']) => <TReturnType extends DataType = string, TInferredOrString = TReturnType extends DataType ? TReturnType : string>(path: PropertyStringPath<TTranslationsObject>, data?: TranslateParams) => TInferredOrString;
4 changes: 2 additions & 2 deletions packages/i18n/dist/createTranslationsLoader.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Translation } from './types';
export declare const loadTranslationFile: (translation: Translation, language: string) => Promise<import("./types").DataRoot>;
import type { Translation } from './types/index.js';
export declare const loadTranslationFile: (translation: Translation, language: string) => Promise<import("./types/index.js").DataRoot>;
type KeysAsStrings<T extends Record<string | number | symbol, unknown>> = keyof T extends string ? keyof T : never;
/**
* Creates a function that can dynamically import translations objects.
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './createTranslate.js';
export * from './createTranslationsLoader.js';
export * from './locale.js';
export * from './localeTo.js';
export type * from './types/index.d.ts';
2 changes: 1 addition & 1 deletion packages/i18n/dist/locale.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**@docs
* This module provide functions to get the current locale and language.
*/
import type { LangInfo, Locale } from './types';
import type { LangInfo, Locale } from './types/index.js';
/**
* This methods deals with isomorphic code and returns the current locale.
* In the browser, it returns the cached locale from the page store.
Expand Down
Loading

0 comments on commit 4b673e3

Please sign in to comment.