@sapphire/plugin-i18next 2.0.0-next.ed5ae33.0 → 2.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/README.md +108 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/InternationalizationHandler.d.ts +2 -2
- package/dist/lib/InternationalizationHandler.d.ts.map +1 -1
- package/dist/lib/InternationalizationHandler.js +16 -11
- package/dist/lib/InternationalizationHandler.js.map +1 -1
- package/dist/lib/functions.d.ts +3 -4
- package/dist/lib/functions.d.ts.map +1 -1
- package/dist/lib/functions.js +1 -1
- package/dist/lib/functions.js.map +1 -1
- package/dist/lib/types.d.ts +2 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
[](https://codecov.io/gh/sapphiredev/plugins)
|
|
11
11
|
[](https://bundlephobia.com/result?p=@sapphire/plugin-in17n)
|
|
12
12
|
[](https://www.npmjs.com/package/@sapphire/plugin-in17n)
|
|
13
|
-
[](https://depfu.com/github/sapphiredev/plugins?project_id=15201)
|
|
14
13
|
|
|
15
14
|
</div>
|
|
16
15
|
|
|
@@ -44,10 +43,112 @@ npm install @sapphire/plugin-i18next @sapphire/framework discord.js
|
|
|
44
43
|
|
|
45
44
|
## Usage
|
|
46
45
|
|
|
46
|
+
This registers the methods and options necessary for message translations in the Sapphire client.
|
|
47
|
+
|
|
47
48
|
```typescript
|
|
49
|
+
// Main bot file
|
|
50
|
+
// Be sure to register the plugin before instantiating the client.
|
|
48
51
|
import '@sapphire/plugin-i18next/register';
|
|
49
52
|
```
|
|
50
53
|
|
|
54
|
+
The basic structure of a translation file is as follows:
|
|
55
|
+
|
|
56
|
+
```jsonc
|
|
57
|
+
// languages/en-US/commands/ping.json
|
|
58
|
+
{
|
|
59
|
+
"success": "Pong!",
|
|
60
|
+
"success_with_args": "Pong! Took me {{latency}}ms to reply"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The `resolveKey` function can be used anywhere to get translated text by its key. In this example, it is used in a method to send a message.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { resolveKey } from '@sapphire/plugin-i18next';
|
|
68
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
69
|
+
import type { Message } from 'discord.js';
|
|
70
|
+
|
|
71
|
+
export class PingCommand extends Command {
|
|
72
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
73
|
+
super(context, {
|
|
74
|
+
...options,
|
|
75
|
+
description: 'ping pong'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public async run(message: Message) {
|
|
80
|
+
await message.channel.send(await resolveKey('commands/ping:success'));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`sendLocalized` will send translated text resolved from a key to a specified channel.
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { sendLocalized } from '@sapphire/plugin-i18next';
|
|
89
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
90
|
+
|
|
91
|
+
import type { Message } from 'discord.js';
|
|
92
|
+
|
|
93
|
+
export class PingCommand extends Command {
|
|
94
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
95
|
+
super(context, {
|
|
96
|
+
...options,
|
|
97
|
+
description: 'ping pong'
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public async run(message: Message) {
|
|
102
|
+
await sendLocalized(message, 'commands/ping:success');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`editLocalized` edits a message, replacing its content with translated text resolved from its key.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { editLocalized } from '@sapphire/plugin-i18next';
|
|
111
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
112
|
+
|
|
113
|
+
import type { Message } from 'discord.js';
|
|
114
|
+
|
|
115
|
+
export class PingCommand extends Command {
|
|
116
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
117
|
+
super(context, {
|
|
118
|
+
...options,
|
|
119
|
+
description: 'ping pong'
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public async run(message: Message) {
|
|
124
|
+
await editLocalized(message, 'commands/ping:success_args', { latency: ws.ping });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`fetchLanguage` returns the guild-specific language that the client is using.
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { fetchLanguage } from '@sapphire/plugin-i18next';
|
|
133
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
134
|
+
|
|
135
|
+
import type { Message } from 'discord.js';
|
|
136
|
+
|
|
137
|
+
export class PingCommand extends Command {
|
|
138
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
139
|
+
super(context, {
|
|
140
|
+
...options,
|
|
141
|
+
description: 'ping pong'
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public async run(message: Message) {
|
|
146
|
+
return message.channel.send(await fetchLanguage(message));
|
|
147
|
+
// ===> en-US
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
51
152
|
## Sapphire i18next Documentation
|
|
52
153
|
|
|
53
154
|
For the full @sapphire/plugin-i18next documentation please refer to the TypeDoc generated [documentation](https://sapphiredev.github.io/plugins/modules/_sapphire_plugin_i18next.html).
|
|
@@ -75,7 +176,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
75
176
|
<table>
|
|
76
177
|
<tr>
|
|
77
178
|
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Favna" title="Code">💻</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-Favna" title="Project Management">📆</a></td>
|
|
78
|
-
<td align="center"><a href="https://
|
|
179
|
+
<td align="center"><a href="https://Quantumlyy.com"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnic</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Quantumlyy" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Quantumlyy" title="Documentation">📖</a></td>
|
|
79
180
|
<td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio Román</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kyranet" title="Code">💻</a></td>
|
|
80
181
|
<td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">👀</a></td>
|
|
81
182
|
<td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
|
|
@@ -83,9 +184,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
83
184
|
<td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=allcontributors[bot]" title="Documentation">📖</a></td>
|
|
84
185
|
</tr>
|
|
85
186
|
<tr>
|
|
86
|
-
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Code">💻</a></td>
|
|
187
|
+
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Documentation">📖</a></td>
|
|
87
188
|
<td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Stitch07" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/issues?q=author%3AStitch07" title="Bug reports">🐛</a></td>
|
|
88
189
|
<td align="center"><a href="https://github.com/PlatinBae"><img src="https://avatars.githubusercontent.com/u/50950966?v=4?s=100" width="100px;" alt=""/><br /><sub><b>PlatinBae</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=PlatinBae" title="Documentation">📖</a></td>
|
|
190
|
+
<td align="center"><a href="https://kaname.netlify.app"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Documentation">📖</a></td>
|
|
191
|
+
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=noftaly" title="Code">💻</a></td>
|
|
192
|
+
<td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Lioness100" title="Code">💻</a></td>
|
|
193
|
+
<td align="center"><a href="https://github.com/UndiedGamer"><img src="https://avatars.githubusercontent.com/u/84702365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UndiedGamer</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=UndiedGamer" title="Code">💻</a></td>
|
|
89
194
|
</tr>
|
|
90
195
|
</table>
|
|
91
196
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./lib/functions"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./lib/InternationalizationHandler"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./lib/types"), exports);
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./lib/functions"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./lib/InternationalizationHandler"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./lib/types"), exports);
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,+DAAgC;AAChC,iFAAkD;AAClD,2DAA4B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Awaitable, NonNullObject } from '@sapphire/utilities';
|
|
2
2
|
import { StringMap, TFunction, TFunctionKeys, TFunctionResult, TOptions } from 'i18next';
|
|
3
3
|
import { i18nextFsBackend } from 'i18next-fs-backend';
|
|
4
4
|
import type { InternationalizationContext, InternationalizationOptions } from './types';
|
|
@@ -81,7 +81,7 @@ export declare class InternationalizationHandler {
|
|
|
81
81
|
* };
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
|
-
fetchLanguage: (context: InternationalizationContext) =>
|
|
84
|
+
fetchLanguage: (context: InternationalizationContext) => Awaitable<string | null>;
|
|
85
85
|
/**
|
|
86
86
|
* Initializes the handler by loading in the namespaces, passing the data to i18next, and filling in the {@link InternationalizationHandler#languages}.
|
|
87
87
|
* @since 1.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternationalizationHandler.d.ts","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"InternationalizationHandler.d.ts","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAc,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClG,OAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAExF;;;GAGG;AACH,qBAAa,2BAA2B;IACvC;;;OAGG;IACI,eAAe,UAAS;IAE/B;;;OAGG;IACI,UAAU,cAAqB;IAEtC;;;OAGG;IACH,SAAgB,SAAS,yBAAgC;IAEzD;;;OAGG;IACH,SAAgB,OAAO,EAAE,2BAA2B,CAAC;IAErD;;;;OAIG;IACH,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAE3C;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,gBAAgB,CAAC,uBAAuB,CAAC;IAE5E;;;;OAIG;gBACgB,OAAO,CAAC,EAAE,2BAA2B;IAgBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACI,aAAa,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAc;IAEtG;;;OAGG;IACU,IAAI;IA+BjB;;;;OAIG;IACI,IAAI,CAAC,MAAM,EAAE,MAAM;IAQ1B;;;;;;;;OAQG;IACI,MAAM,CACZ,OAAO,SAAS,eAAe,GAAG,MAAM,EACxC,KAAK,SAAS,aAAa,GAAG,MAAM,EACpC,iBAAiB,SAAS,aAAa,GAAG,SAAS,EAClD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,OAAO;IAavF;;;;;;OAMG;IACU,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAO,EAAE,OAAO,SAAK;;;;CAoBvF"}
|
|
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const pieces_1 = require("@sapphire/pieces");
|
|
6
6
|
const utilities_1 = require("@sapphire/utilities");
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
|
-
const i18next_1 = tslib_1.__importDefault(require("i18next"));
|
|
9
|
-
const i18next_fs_backend_1 = tslib_1.__importDefault(require("i18next-fs-backend"));
|
|
8
|
+
const i18next_1 = (0, tslib_1.__importDefault)(require("i18next"));
|
|
9
|
+
const i18next_fs_backend_1 = (0, tslib_1.__importDefault)(require("i18next-fs-backend"));
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
/**
|
|
12
12
|
* A generalized class for handling `i18next` JSON files and their discovery.
|
|
@@ -123,14 +123,15 @@ class InternationalizationHandler {
|
|
|
123
123
|
writable: true,
|
|
124
124
|
value: () => null
|
|
125
125
|
});
|
|
126
|
-
this.options = options ?? {};
|
|
127
|
-
this.languagesDirectory =
|
|
126
|
+
this.options = options ?? { i18next: { ignoreJSONStructure: false } };
|
|
127
|
+
this.languagesDirectory =
|
|
128
|
+
this.options.defaultLanguageDirectory ?? (0, path_1.join)(pieces_1.container.client?.options?.baseUserDirectory ?? (0, pieces_1.getRootData)().root, 'languages');
|
|
128
129
|
this.backendOptions = {
|
|
129
|
-
loadPath: path_1.join(this.languagesDirectory, '{{lng}}', '{{ns}}.json'),
|
|
130
|
+
loadPath: (0, path_1.join)(this.languagesDirectory, '{{lng}}', '{{ns}}.json'),
|
|
130
131
|
addPath: this.languagesDirectory,
|
|
131
132
|
...this.options.backend
|
|
132
133
|
};
|
|
133
|
-
if (utilities_1.isFunction(this.options.fetchLanguage)) {
|
|
134
|
+
if ((0, utilities_1.isFunction)(this.options.fetchLanguage)) {
|
|
134
135
|
this.fetchLanguage = this.options.fetchLanguage;
|
|
135
136
|
}
|
|
136
137
|
}
|
|
@@ -140,7 +141,9 @@ class InternationalizationHandler {
|
|
|
140
141
|
*/
|
|
141
142
|
async init() {
|
|
142
143
|
const { namespaces, languages } = await this.walkLanguageDirectory(this.languagesDirectory);
|
|
143
|
-
const userOptions = utilities_1.isFunction(this.options.i18next) ? this.options.i18next(namespaces, languages) : this.options.i18next;
|
|
144
|
+
const userOptions = (0, utilities_1.isFunction)(this.options.i18next) ? this.options.i18next(namespaces, languages) : this.options.i18next;
|
|
145
|
+
const ignoreJSONStructure = userOptions?.ignoreJSONStructure ?? false;
|
|
146
|
+
const skipOnVariables = userOptions?.interpolation?.skipOnVariables ?? false;
|
|
144
147
|
i18next_1.default.use(i18next_fs_backend_1.default);
|
|
145
148
|
await i18next_1.default.init({
|
|
146
149
|
backend: this.backendOptions,
|
|
@@ -148,13 +151,15 @@ class InternationalizationHandler {
|
|
|
148
151
|
initImmediate: false,
|
|
149
152
|
interpolation: {
|
|
150
153
|
escapeValue: false,
|
|
151
|
-
...userOptions?.interpolation
|
|
154
|
+
...userOptions?.interpolation,
|
|
155
|
+
skipOnVariables
|
|
152
156
|
},
|
|
153
157
|
load: 'all',
|
|
154
158
|
defaultNS: 'default',
|
|
155
159
|
ns: namespaces,
|
|
156
160
|
preload: languages,
|
|
157
|
-
...userOptions
|
|
161
|
+
...userOptions,
|
|
162
|
+
ignoreJSONStructure
|
|
158
163
|
});
|
|
159
164
|
this.namespaces = new Set(namespaces);
|
|
160
165
|
for (const item of languages) {
|
|
@@ -203,7 +208,7 @@ class InternationalizationHandler {
|
|
|
203
208
|
* @since 1.0.0
|
|
204
209
|
*/
|
|
205
210
|
async walkLanguageDirectory(dir, namespaces = [], current = '') {
|
|
206
|
-
const directory = await promises_1.opendir(dir);
|
|
211
|
+
const directory = await (0, promises_1.opendir)(dir);
|
|
207
212
|
const languages = [];
|
|
208
213
|
for await (const entry of directory) {
|
|
209
214
|
const fn = entry.name;
|
|
@@ -213,7 +218,7 @@ class InternationalizationHandler {
|
|
|
213
218
|
const isLanguage = fn.includes('-');
|
|
214
219
|
if (isLanguage)
|
|
215
220
|
languages.push(fn);
|
|
216
|
-
({ namespaces } = await this.walkLanguageDirectory(path_1.join(dir, fn), namespaces, isLanguage ? '' : `${fn}/`));
|
|
221
|
+
({ namespaces } = await this.walkLanguageDirectory((0, path_1.join)(dir, fn), namespaces, isLanguage ? '' : `${fn}/`));
|
|
217
222
|
}
|
|
218
223
|
else if (entry.name.endsWith('.json')) {
|
|
219
224
|
namespaces.push(`${current}${fn.substr(0, fn.length - 5)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternationalizationHandler.js","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"InternationalizationHandler.js","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":";;;;AAAA,6CAA0D;AAC1D,mDAA2E;AAC3E,0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gBACrD,oCAAoC;gBACpC,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACpC,IAAI,UAAU;oBAAE,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAEnC,CAAC,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAA,WAAI,EAAC,GAAG,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;aAC3G;iBAAM,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACxC,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;aAC5D;SACD;QAED,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5D,CAAC;CACD;AAvMD,kEAuMC"}
|
package/dist/lib/functions.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { NonNullObject } from '@sapphire/utilities';
|
|
|
2
2
|
import { Guild, Message, MessageOptions } from 'discord.js';
|
|
3
3
|
import type { StringMap, TFunctionKeys, TFunctionResult, TOptions } from 'i18next';
|
|
4
4
|
import type { DiscordChannel } from './types';
|
|
5
|
-
declare type ChannelTarget = Message | DiscordChannel;
|
|
6
|
-
declare type Target = ChannelTarget | Guild;
|
|
5
|
+
export declare type ChannelTarget = Message | DiscordChannel;
|
|
6
|
+
export declare type Target = ChannelTarget | Guild;
|
|
7
7
|
/**
|
|
8
8
|
* Retrieves the language name for a specific target, using {@link InternationalizationHandler.fetchLanguage}, and if it
|
|
9
9
|
* returns a nullish value, then it falls back to {@link Guild.preferredLocale}, then
|
|
@@ -77,7 +77,7 @@ export declare function sendLocalized<TKeys extends TFunctionKeys = string, TInt
|
|
|
77
77
|
* @param options The options to be sent, requiring at least `keys` to be passed.
|
|
78
78
|
* @example
|
|
79
79
|
* ```typescript
|
|
80
|
-
* await
|
|
80
|
+
* await editLocalized(message, 'commands/ping:success');
|
|
81
81
|
* // ➡ "Pong!"
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
@@ -105,5 +105,4 @@ export declare function editLocalized<TKeys extends TFunctionKeys = string>(targ
|
|
|
105
105
|
* ```
|
|
106
106
|
*/
|
|
107
107
|
export declare function editLocalized<TKeys extends TFunctionKeys = string, TInterpolationMap extends NonNullObject = StringMap>(target: Message, options: LocalizedMessageOptions<TKeys, TInterpolationMap>): Promise<Message>;
|
|
108
|
-
export {};
|
|
109
108
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAwD,MAAM,SAAS,CAAC;AAEpG,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EA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,GAAG,MAAM,EAAE,iBAAiB,SAAS,aAAa,GAAG,SAAS,EAC5H,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,CAAC,GACxD,OAAO,CAAC,OAAO,CAAC,CAAC;AASpB;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,KAAK,SAAS,aAAa,GAAG,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACpI;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,KAAK,SAAS,aAAa,GAAG,MAAM,EAAE,iBAAiB,SAAS,aAAa,GAAG,SAAS,EAC5H,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,CAAC,GACxD,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/lib/functions.js
CHANGED
|
@@ -82,7 +82,7 @@ function resolveTextChannel(target) {
|
|
|
82
82
|
* @private
|
|
83
83
|
*/
|
|
84
84
|
async function resolveOverloads(target, options) {
|
|
85
|
-
if (utilities_1.isObject(options)) {
|
|
85
|
+
if ((0, utilities_1.isObject)(options)) {
|
|
86
86
|
const casted = options;
|
|
87
87
|
return { ...options, content: await resolveKey(target, casted.keys, casted.formatOptions) };
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/lib/functions.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,mDAA8D;AAC9D,2CAA4D;AAO5D;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,MAAc;IAC3C,kBAAkB;IAClB,IAAI,MAAM,YAAY,oBAAO,EAAE;QAC9B,OAAO,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAA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EG;AACH,KAAK,UAAU,eAAe,CAAC,OAAoC;IAClE,MAAM,IAAI,GAAG,MAAM,kBAAS,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,eAAe,IAAI,kBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC;AAChG,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAAqB;IAChD,IAAI,MAAM,YAAY,oBAAO;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,MAAM,CAAC;IACnC,MAAM,IAAI,SAAS,CAAC,kBAAkB,MAAM,CAAC,IAAI,2BAA2B,CAAC,CAAC;AAC/E,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,gBAAgB,CAC9B,MAAc,EACd,OAA4E;IAE5E,IAAI,IAAA,oBAAQ,EAAC,OAAO,CAAC,EAAE;QACtB,MAAM,MAAM,GAAG,OAA4D,CAAC;QAC5E,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;KAC5F;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Awaitable } from '@sapphire/utilities';
|
|
2
2
|
import type { Guild, Message, StageChannel, StoreChannel, User, VoiceChannel } from 'discord.js';
|
|
3
3
|
import type { InitOptions } from 'i18next';
|
|
4
4
|
import type { i18nextFsBackend } from 'i18next-fs-backend';
|
|
@@ -57,7 +57,7 @@ export interface InternationalizationOptions {
|
|
|
57
57
|
* @since 2.0.0
|
|
58
58
|
* @default () => InternationalizationOptions.defaultName
|
|
59
59
|
*/
|
|
60
|
-
fetchLanguage?: (context: InternationalizationContext) =>
|
|
60
|
+
fetchLanguage?: (context: InternationalizationContext) => Awaitable<string | null>;
|
|
61
61
|
}
|
|
62
62
|
export declare type TextBasedDiscordChannel = Message['channel'];
|
|
63
63
|
export declare type DiscordChannel = TextBasedDiscordChannel | StoreChannel | StageChannel | VoiceChannel;
|
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,
|
|
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,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;GAIG;AACH,oBAAY,cAAc,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAErG;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,uBAAuB,CAAC;IAEnD;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IAEpD;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACnF;AAED,oBAAY,uBAAuB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACzD,oBAAY,cAAc,GAAG,uBAAuB,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC;AAElG;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC3C,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,iCAAiC;IACjD,IAAI,CAAC,EAAE,2BAA2B,CAAC;CACnC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-i18next",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Plugin for @sapphire/framework to support i18next.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.mjs",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
|
+
"typedocMain": "src/index.ts",
|
|
10
11
|
"exports": {
|
|
11
12
|
".": {
|
|
12
13
|
"import": "./dist/index.mjs",
|
|
@@ -27,16 +28,15 @@
|
|
|
27
28
|
"scripts": {
|
|
28
29
|
"test": "jest",
|
|
29
30
|
"lint": "eslint src tests --ext ts --fix",
|
|
30
|
-
"build": "tsc -b src",
|
|
31
|
-
"postbuild": "run-p esm:**",
|
|
31
|
+
"build": "tsc -b src && yarn esm:register && yarn esm:default",
|
|
32
32
|
"esm:register": "gen-esm-wrapper dist/register.js dist/register.mjs",
|
|
33
33
|
"esm:default": "gen-esm-wrapper dist/index.js dist/index.mjs",
|
|
34
34
|
"prepublishOnly": "yarn build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@sapphire/utilities": "^
|
|
38
|
-
"@types/i18next-fs-backend": "^1.
|
|
39
|
-
"i18next": "^
|
|
37
|
+
"@sapphire/utilities": "^3.0.3",
|
|
38
|
+
"@types/i18next-fs-backend": "^1.1.2",
|
|
39
|
+
"i18next": "^21.3.1",
|
|
40
40
|
"i18next-fs-backend": "^1.1.1",
|
|
41
41
|
"tslib": "^2.3.1"
|
|
42
42
|
},
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"register.*"
|
|
52
52
|
],
|
|
53
53
|
"engines": {
|
|
54
|
-
"node": ">=
|
|
55
|
-
"npm": ">=
|
|
54
|
+
"node": ">=v14.18.0",
|
|
55
|
+
"npm": ">=7.24.2"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"sapphiredev",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e3d1ccc0ae912fbf13313c83bb322d613661e2ad"
|
|
76
76
|
}
|