@sapphire/plugin-i18next 6.0.0-pr-475.db0d5cc.0 → 6.0.0
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 +13 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/InternationalizationHandler.d.ts +4 -4
- package/dist/lib/InternationalizationHandler.d.ts.map +1 -1
- package/dist/lib/InternationalizationHandler.js +7 -5
- package/dist/lib/InternationalizationHandler.js.map +1 -1
- package/dist/lib/functions.d.ts +9 -9
- package/dist/lib/functions.d.ts.map +1 -1
- package/dist/lib/functions.js +7 -2
- package/dist/lib/functions.js.map +1 -1
- package/dist/lib/types.d.ts +11 -3
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/register.d.ts +1 -10
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +3 -2
- package/dist/register.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@sapphire/plugin-i18next@6.0.0](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-i18next@6.0.0...@sapphire/plugin-i18next@6.0.0) - (2023-09-06)
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
- **i18next:** Update to i18next v23 (#475) ([4030137](https://github.com/sapphiredev/plugins/commit/403013750da1b00228d5b0ff0db1111566d11c62))
|
|
10
|
+
- 💥 **BREAKING CHANGE:** This library now depends on i18next v23. See their migration guide as well: https://www.i18next.com/misc/migration-guide#v22.x.x-to-v23.0.0
|
|
11
|
+
|
|
12
|
+
# [@sapphire/plugin-i18next@5.1.1](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-i18next@5.1.1...@sapphire/plugin-i18next@5.1.1) - (2023-09-06)
|
|
13
|
+
|
|
14
|
+
## 🐛 Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **i18next:** Move module augmentations to `index` and import in `register` (#477) ([9c098d6](https://github.com/sapphiredev/plugins/commit/9c098d60bb3b2be116d44a547768e7e7c9054c00))
|
|
17
|
+
|
|
5
18
|
# [@sapphire/plugin-i18next@5.1.0](https://github.com/sapphiredev/plugins/compare/@sapphire/plugin-i18next@5.0.5...@sapphire/plugin-i18next@5.1.0) - (2023-08-29)
|
|
6
19
|
|
|
7
20
|
## 🚀 Features
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import type { InternationalizationHandler } from './lib/InternationalizationHandler';
|
|
2
|
+
import type { InternationalizationClientOptions } from './lib/types';
|
|
1
3
|
export type { TFunction, TOptions } from 'i18next';
|
|
2
4
|
export * from './lib/InternationalizationHandler';
|
|
3
5
|
export * from './lib/functions';
|
|
4
6
|
export * from './lib/types';
|
|
7
|
+
declare module '@sapphire/pieces' {
|
|
8
|
+
interface Container {
|
|
9
|
+
i18n: InternationalizationHandler;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare module 'discord.js' {
|
|
13
|
+
interface ClientOptions extends InternationalizationClientOptions {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAErE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAE5B,OAAO,QAAQ,kBAAkB,CAAC;IACjC,UAAU,SAAS;QAClB,IAAI,EAAE,2BAA2B,CAAC;KAClC;CACD;AAED,OAAO,QAAQ,YAAY,CAAC;IAC3B,UAAiB,aAAc,SAAQ,iCAAiC;KAAG;CAC3E"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAIA,oEAAkD;AAClD,kDAAgC;AAChC,8CAA4B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type Awaitable } from '@sapphire/utilities';
|
|
3
3
|
import { Backend } from '@skyra/i18next-backend';
|
|
4
|
-
import { type TFunction, type TOptions } from 'i18next';
|
|
4
|
+
import { AppendKeyPrefix, InterpolationMap, Namespace, ParseKeys, TFunctionReturn, TFunctionReturnOptionalDetails, type TFunction, type TOptions } from 'i18next';
|
|
5
5
|
import type { PathLike } from 'node:fs';
|
|
6
|
-
import type { InternationalizationContext, InternationalizationOptions
|
|
6
|
+
import type { $Dictionary, InternationalizationContext, InternationalizationOptions } from './types';
|
|
7
7
|
/**
|
|
8
8
|
* A generalized class for handling `i18next` JSON files and their discovery.
|
|
9
9
|
* @since 1.0.0
|
|
@@ -104,9 +104,9 @@ export declare class InternationalizationHandler {
|
|
|
104
104
|
* @see {@link https://www.i18next.com/overview/api#t}
|
|
105
105
|
* @returns The localized content.
|
|
106
106
|
*/
|
|
107
|
-
format<const Key extends
|
|
107
|
+
format<const Key extends ParseKeys<Ns, TOpt, undefined>, const TOpt extends TOptions, Ns extends Namespace, Ret extends TFunctionReturn<Ns, AppendKeyPrefix<Key, undefined>, TOpt>, const ActualOptions extends TOpt & InterpolationMap<Ret> = TOpt & InterpolationMap<Ret>>(locale: string, ...[key, defaultValueOrOptions, optionsOrUndefined]: [key: Key | Key[], options?: ActualOptions] | [key: string | string[], options: TOpt & $Dictionary & {
|
|
108
108
|
defaultValue: string;
|
|
109
|
-
}):
|
|
109
|
+
}] | [key: string | string[], defaultValue: string | undefined, options?: TOpt & $Dictionary]): TFunctionReturnOptionalDetails<Ret, TOpt>;
|
|
110
110
|
/**
|
|
111
111
|
* @param directory The directory that should be walked.
|
|
112
112
|
* @since 3.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternationalizationHandler.d.ts","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAuB,MAAM,wBAAwB,CAAC;AACtE,OAAgB,
|
|
1
|
+
{"version":3,"file":"InternationalizationHandler.d.ts","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAuB,MAAM,wBAAwB,CAAC;AACtE,OAAgB,EACf,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,eAAe,EACf,8BAA8B,EAC9B,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAErG;;;GAGG;AACH,qBAAa,2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YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,GAChF,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG,WAAW,CAAC,GACzF,8BAA8B,CAAC,GAAG,EAAE,IAAI,CAAC;IAgB5C;;;OAGG;IACU,iBAAiB,CAAC,SAAS,EAAE,QAAQ;;;;IAoBrC,eAAe;IAiB5B;;;;;OAKG;YACY,mBAAmB;CAUlC"}
|
|
@@ -202,16 +202,18 @@ class InternationalizationHandler {
|
|
|
202
202
|
* @see {@link https://www.i18next.com/overview/api#t}
|
|
203
203
|
* @returns The localized content.
|
|
204
204
|
*/
|
|
205
|
-
format(locale, key,
|
|
205
|
+
format(locale, ...[key, defaultValueOrOptions, optionsOrUndefined]) {
|
|
206
206
|
if (!this.languagesLoaded)
|
|
207
207
|
throw new Error('Cannot call this method until InternationalizationHandler#init has been called');
|
|
208
208
|
const language = this.languages.get(locale);
|
|
209
209
|
if (!language)
|
|
210
210
|
throw new ReferenceError('Invalid language provided');
|
|
211
|
-
const
|
|
212
|
-
?
|
|
213
|
-
:
|
|
214
|
-
|
|
211
|
+
const defaultValue = typeof defaultValueOrOptions === 'string'
|
|
212
|
+
? defaultValueOrOptions
|
|
213
|
+
: this.options.defaultMissingKey
|
|
214
|
+
? language(this.options.defaultMissingKey, { replace: { key } })
|
|
215
|
+
: '';
|
|
216
|
+
return language(key, defaultValue, optionsOrUndefined);
|
|
215
217
|
}
|
|
216
218
|
/**
|
|
217
219
|
* @param directory The directory that should be walked.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternationalizationHandler.js","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":";;;;;;AAAA,mDAA6C;AAC7C,6CAA0D;AAC1D,mDAAiE;AACjE,4DAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"InternationalizationHandler.js","sourceRoot":"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C,EAAE;gBAC1D,MAAM,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxC;SACD;IACF,CAAC;CACD;AA9PD,kEA8PC"}
|
package/dist/lib/functions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type APIApplicationCommandOptionChoice } from 'discord.js';
|
|
2
|
-
import type { TOptions } from 'i18next';
|
|
3
|
-
import type { BuilderWithDescription, BuilderWithName, BuilderWithNameAndDescription, LocalizedData,
|
|
2
|
+
import type { AppendKeyPrefix, DefaultNamespace, InterpolationMap, Namespace, ParseKeys, TFunctionReturn, TFunctionReturnOptionalDetails, TOptions } from 'i18next';
|
|
3
|
+
import type { $Dictionary, $SpecialObject, BuilderWithDescription, BuilderWithName, BuilderWithNameAndDescription, LocalizedData, Target } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the language name for a specific target, using {@link InternationalizationHandler.fetchLanguage}.
|
|
6
6
|
* If {@link InternationalizationHandler.fetchLanguage} is not defined or this function returns a nullish value,
|
|
@@ -29,30 +29,30 @@ export declare function fetchT(target: Target): Promise<import("i18next").TFunct
|
|
|
29
29
|
* @param options The options to be passed to TFunction.
|
|
30
30
|
* @returns The data that `key` held, processed by i18next.
|
|
31
31
|
*/
|
|
32
|
-
export declare function resolveKey<const Key extends
|
|
32
|
+
export declare function resolveKey<const Key extends ParseKeys<Ns, TOpt, undefined>, const TOpt extends TOptions = TOptions, Ret extends TFunctionReturn<Ns, AppendKeyPrefix<Key, undefined>, TOpt> = TOpt['returnObjects'] extends true ? $SpecialObject : string, Ns extends Namespace = DefaultNamespace, const ActualOptions extends TOpt & InterpolationMap<Ret> = TOpt & InterpolationMap<Ret>>(target: Target, ...[key, defaultValueOrOptions, optionsOrUndefined]: [key: Key | Key[], options?: ActualOptions] | [key: string | string[], options: TOpt & $Dictionary & {
|
|
33
33
|
defaultValue: string;
|
|
34
|
-
}): Promise<
|
|
34
|
+
}] | [key: string | string[], defaultValue: string, options?: TOpt & $Dictionary]): Promise<TFunctionReturnOptionalDetails<Ret, TOpt>>;
|
|
35
35
|
/**
|
|
36
36
|
* Gets the value and the localizations from a language key.
|
|
37
37
|
* @param key The key to get the localizations from.
|
|
38
38
|
* @returns The retrieved data.
|
|
39
39
|
* @remarks This should be called **strictly** after loading the locales.
|
|
40
40
|
*/
|
|
41
|
-
export declare function getLocalizedData(key:
|
|
41
|
+
export declare function getLocalizedData<const TOpt extends TOptions = TOptions, Ns extends Namespace = DefaultNamespace, KPrefix = undefined>(key: ParseKeys<Ns, TOpt, KPrefix>): LocalizedData;
|
|
42
42
|
/**
|
|
43
43
|
* Applies the localized names on the builder, calling `setName` and `setNameLocalizations`.
|
|
44
44
|
* @param builder The builder to apply the localizations to.
|
|
45
45
|
* @param key The key to get the localizations from.
|
|
46
46
|
* @returns The updated builder.
|
|
47
47
|
*/
|
|
48
|
-
export declare function applyNameLocalizedBuilder<T extends BuilderWithName>(builder: T, key:
|
|
48
|
+
export declare function applyNameLocalizedBuilder<T extends BuilderWithName, const TOpt extends TOptions = TOptions, Ns extends Namespace = DefaultNamespace, KPrefix = undefined>(builder: T, key: ParseKeys<Ns, TOpt, KPrefix>): T;
|
|
49
49
|
/**
|
|
50
50
|
* Applies the localized descriptions on the builder, calling `setDescription` and `setDescriptionLocalizations`.
|
|
51
51
|
* @param builder The builder to apply the localizations to.
|
|
52
52
|
* @param key The key to get the localizations from.
|
|
53
53
|
* @returns The updated builder.
|
|
54
54
|
*/
|
|
55
|
-
export declare function applyDescriptionLocalizedBuilder<T extends BuilderWithDescription>(builder: T, key:
|
|
55
|
+
export declare function applyDescriptionLocalizedBuilder<T extends BuilderWithDescription, const TOpt extends TOptions = TOptions, Ns extends Namespace = DefaultNamespace, KPrefix = undefined>(builder: T, key: ParseKeys<Ns, TOpt, KPrefix>): T;
|
|
56
56
|
/**
|
|
57
57
|
* Applies the localized names and descriptions on the builder, calling {@link applyNameLocalizedBuilder} and
|
|
58
58
|
* {@link applyDescriptionLocalizedBuilder}.
|
|
@@ -105,7 +105,7 @@ export declare function applyDescriptionLocalizedBuilder<T extends BuilderWithDe
|
|
|
105
105
|
* }
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
|
-
export declare function applyLocalizedBuilder<T extends BuilderWithNameAndDescription>(builder: T, ...params: [root: string] | [name:
|
|
108
|
+
export declare function applyLocalizedBuilder<T extends BuilderWithNameAndDescription, const TOpt extends TOptions = TOptions, Ns extends Namespace = DefaultNamespace, KPrefix = undefined>(builder: T, ...params: [root: string] | [name: ParseKeys<Ns, TOpt, KPrefix>, description: ParseKeys<Ns, TOpt, KPrefix>]): T;
|
|
109
109
|
/**
|
|
110
110
|
* Constructs an object that can be passed into `setChoices` for String or Number option with localized names.
|
|
111
111
|
*
|
|
@@ -133,5 +133,5 @@ export declare function applyLocalizedBuilder<T extends BuilderWithNameAndDescri
|
|
|
133
133
|
* }
|
|
134
134
|
* ```
|
|
135
135
|
*/
|
|
136
|
-
export declare function createLocalizedChoice<ValueType = string | number>(key:
|
|
136
|
+
export declare function createLocalizedChoice<ValueType = string | number, const TOpt extends TOptions = TOptions, Ns extends Namespace = DefaultNamespace, KPrefix = undefined>(key: ParseKeys<Ns, TOpt, KPrefix>, options: Omit<APIApplicationCommandOptionChoice<ValueType>, 'name' | 'name_localizations'>): APIApplicationCommandOptionChoice<ValueType>;
|
|
137
137
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,iCAAiC,EAAqB,MAAM,YAAY,CAAC;AAC7I,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwD,KAAK,iCAAiC,EAAqB,MAAM,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AAC,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAU5H;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CACpC,SAAS,GAAG,MAAM,GAAG,MAAM,EAC3B,KAAK,CAAC,IAAI,SAAS,QAAQ,GAAG,QAAQ,EACtC,EAAE,SAAS,SAAS,GAAG,gBAAgB,EACvC,OAAO,GAAG,SAAS,EAEnB,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,IAAI,CAAC,iCAAiC,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC,GACxF,iCAAiC,CAAC,SAAS,CAAC,CAQ9C"}
|
package/dist/lib/functions.js
CHANGED
|
@@ -61,8 +61,13 @@ exports.fetchT = fetchT;
|
|
|
61
61
|
* @param options The options to be passed to TFunction.
|
|
62
62
|
* @returns The data that `key` held, processed by i18next.
|
|
63
63
|
*/
|
|
64
|
-
async function resolveKey(target, key,
|
|
65
|
-
|
|
64
|
+
async function resolveKey(target, ...[key, defaultValueOrOptions, optionsOrUndefined]) {
|
|
65
|
+
const parsedOptions = typeof defaultValueOrOptions === 'string' ? optionsOrUndefined : defaultValueOrOptions;
|
|
66
|
+
const language = typeof parsedOptions?.lng === 'string' ? parsedOptions.lng : await fetchLanguage(target);
|
|
67
|
+
if (typeof defaultValueOrOptions === 'string') {
|
|
68
|
+
return pieces_1.container.i18n.format(language, key, defaultValueOrOptions, optionsOrUndefined);
|
|
69
|
+
}
|
|
70
|
+
return pieces_1.container.i18n.format(language, key, undefined, optionsOrUndefined);
|
|
66
71
|
}
|
|
67
72
|
exports.resolveKey = resolveKey;
|
|
68
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA2C;AAC3C,2CAA6I;
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA2C;AAC3C,2CAA6I;AAsB7I;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,MAAc;IAC3C,uBAAuB;IACvB,IAAI,MAAM,YAAY,4BAAe,EAAE;QACtC,OAAO,eAAe,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,sBAAsB,EAAE,MAAM,CAAC,WAAW;YAC1C,iBAAiB,EAAE,MAAM,CAAC,MAAM;SAChC,CAAC,CAAC;KACH;IAED,kBAAkB;IAClB,IAAI,MAAM,YAAY,oBAAO,EAAE;QAC9B,OAAO,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;KAC9F;IAED,gBAAgB;IAChB,IAAI,MAAM,YAAY,kBAAK,EAAE;QAC5B,OAAO,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;KACrE;IAED,oBAAoB;IACpB,IAAI,MAAM,CAAC,IAAI,KAAK,wBAAW,CAAC,EAAE,EAAE;QACnC,OAAO,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;KACrE;IAED,4BAA4B;IAC5B,O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AAC,CAAC,CAAC,MAAuB,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,aAA8B,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAElH,yBAAyB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/C,gCAAgC,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AAChB,CAAC;AAfD,sDAeC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,qBAAqB,CAMpC,GAAiC,EACjC,OAA0F;IAE1F,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAErC,OAAO;QACN,GAAG,OAAO;QACV,IAAI,EAAE,MAAM,CAAC,KAAK;QAClB,kBAAkB,EAAE,MAAM,CAAC,aAAa;KACxC,CAAC;AACH,CAAC;AAhBD,sDAgBC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -2,11 +2,19 @@ import type { Awaitable } from '@sapphire/utilities';
|
|
|
2
2
|
import type { Backend } from '@skyra/i18next-backend';
|
|
3
3
|
import type { WatchOptions } from 'chokidar';
|
|
4
4
|
import type { BaseInteraction, Guild, Interaction, LocalizationMap, Message, StageChannel, User, VoiceChannel } from 'discord.js';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
5
|
+
import type { InitOptions } from 'i18next';
|
|
6
|
+
/**
|
|
7
|
+
* This is a re-exported type from i18next.
|
|
8
|
+
* It is essentially an object of key-value pairs, where the key is a string and the value is any.
|
|
9
|
+
*/
|
|
10
|
+
export interface $Dictionary {
|
|
7
11
|
[key: string]: any;
|
|
8
12
|
}
|
|
9
|
-
|
|
13
|
+
/**
|
|
14
|
+
* This is a re-exported type from i18next.
|
|
15
|
+
* It is the returned type from `resolveKey` when `returnObjects` is `true` in the options.
|
|
16
|
+
*/
|
|
17
|
+
export type $SpecialObject = $Dictionary | Array<string | $Dictionary>;
|
|
10
18
|
/**
|
|
11
19
|
* Configure whether to use Hot-Module-Replacement (HMR) for your i18next resources using these options. The minimum config to enable HMR is to set `enabled` to true. Any other properties are optional.
|
|
12
20
|
* @since 2.2.0
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAClI,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAClI,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,UAAU;IAC1B;;;OAGG;IACH,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6E;IAC7E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,oDAAoD;IACpD,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,sBAAsB,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAC;IACpD,iBAAiB,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,iCAAiC;IACjD,IAAI,CAAC,EAAE,2BAA2B,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC;CAClE;AAED,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC/B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oBAAoB,CAAC,cAAc,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,sBAAsB;IACtC,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,2BAA2B,CAAC,qBAAqB,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC;CACjF;AAED,MAAM,MAAM,6BAA6B,GAAG,eAAe,GAAG,sBAAsB,CAAC;AACrF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,cAAc,CAAC;AACrD,MAAM,MAAM,MAAM,GAAG,eAAe,GAAG,aAAa,GAAG,KAAK,CAAC"}
|
package/dist/register.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
+
import './index';
|
|
1
2
|
import { Plugin, SapphireClient, postLogin, preGenericsInitialization, preLogin } from '@sapphire/framework';
|
|
2
3
|
import type { ClientOptions } from 'discord.js';
|
|
3
|
-
import { InternationalizationHandler, type InternationalizationClientOptions } from './index';
|
|
4
4
|
export declare class I18nextPlugin extends Plugin {
|
|
5
5
|
static [preGenericsInitialization](this: SapphireClient, options: ClientOptions): void;
|
|
6
6
|
static [preLogin](this: SapphireClient): Promise<void>;
|
|
7
7
|
static [postLogin](this: SapphireClient): void;
|
|
8
8
|
}
|
|
9
|
-
declare module '@sapphire/pieces' {
|
|
10
|
-
interface Container {
|
|
11
|
-
i18n: InternationalizationHandler;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare module 'discord.js' {
|
|
15
|
-
interface ClientOptions extends InternationalizationClientOptions {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
9
|
//# sourceMappingURL=register.d.ts.map
|
package/dist/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAa,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAa,SAAS,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,qBAAa,aAAc,SAAQ,MAAM;WAC1B,CAAC,yBAAyB,CAAC,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;WAIzE,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;WAIrD,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;CAQrD"}
|
package/dist/register.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.I18nextPlugin = void 0;
|
|
4
|
+
require("./index");
|
|
4
5
|
const framework_1 = require("@sapphire/framework");
|
|
5
6
|
const chokidar_1 = require("chokidar");
|
|
6
|
-
const
|
|
7
|
+
const InternationalizationHandler_1 = require("./lib/InternationalizationHandler");
|
|
7
8
|
class I18nextPlugin extends framework_1.Plugin {
|
|
8
9
|
static [framework_1.preGenericsInitialization](options) {
|
|
9
|
-
framework_1.container.i18n = new
|
|
10
|
+
framework_1.container.i18n = new InternationalizationHandler_1.InternationalizationHandler(options.i18n);
|
|
10
11
|
}
|
|
11
12
|
static async [framework_1.preLogin]() {
|
|
12
13
|
await framework_1.container.i18n.init();
|
package/dist/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,mDAAwH;AACxH,uCAAiC;
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,mBAAiB;AACjB,mDAAwH;AACxH,uCAAiC;AAEjC,mFAAgF;AAEhF,MAAa,aAAc,SAAQ,kBAAM;IACjC,MAAM,CAAC,CAAC,qCAAyB,CAAC,CAAuB,OAAsB;QACrF,qBAAS,CAAC,IAAI,GAAG,IAAI,yDAA2B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAQ,CAAC;QAC7B,MAAM,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,CAAC,qBAAS,CAAC;QACxB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE;YACpC,qBAAS,CAAC,MAAM,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;YACxF,MAAM,GAAG,GAAG,IAAA,gBAAK,EAAC,qBAAS,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEpF,KAAK,MAAM,KAAK,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBAAE,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,qBAAS,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;SAChG;IACF,CAAC;CACD;AAjBD,sCAiBC;AAED,0BAAc,CAAC,OAAO,CAAC,8BAA8B,CAAC,aAAa,CAAC,qCAAyB,CAAC,EAAE,mCAAmC,CAAC,CAAC;AACrI,0BAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC,aAAa,CAAC,oBAAQ,CAAC,EAAE,kBAAkB,CAAC,CAAC;AACzF,0BAAc,CAAC,OAAO,CAAC,qBAAqB,CAAC,aAAa,CAAC,qBAAS,CAAC,EAAE,mBAAmB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-i18next",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Plugin for @sapphire/framework to support i18next.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@sapphire/utilities": "^3.13.0",
|
|
40
|
-
"@skyra/i18next-backend": "^2.0.
|
|
40
|
+
"@skyra/i18next-backend": "^2.0.4",
|
|
41
41
|
"chokidar": "^3.5.3",
|
|
42
|
-
"i18next": "^23.4.
|
|
42
|
+
"i18next": "^23.4.9"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@favware/cliff-jumper": "^2.1.2",
|
|
77
77
|
"gen-esm-wrapper": "^1.1.3",
|
|
78
|
-
"typedoc": "^0.25.
|
|
78
|
+
"typedoc": "^0.25.1",
|
|
79
79
|
"typedoc-json-parser": "^8.2.0",
|
|
80
80
|
"typescript": "^5.2.2"
|
|
81
81
|
}
|