@sapphire/plugin-i18next 2.0.0-next.d3a40b7.0 → 2.0.0-next.d810c56.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 +103 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/InternationalizationHandler.d.ts.map +1 -1
- package/dist/lib/InternationalizationHandler.js +12 -10
- package/dist/lib/InternationalizationHandler.js.map +1 -1
- package/dist/lib/functions.d.ts +1 -1
- package/dist/lib/functions.js +1 -1
- package/dist/lib/functions.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -44,10 +44,112 @@ npm install @sapphire/plugin-i18next @sapphire/framework discord.js
|
|
|
44
44
|
|
|
45
45
|
## Usage
|
|
46
46
|
|
|
47
|
+
This registers the methods and options necessary for message translations in the Sapphire client.
|
|
48
|
+
|
|
47
49
|
```typescript
|
|
50
|
+
// Main bot file
|
|
51
|
+
// Be sure to register the plugin before instantiating the client.
|
|
48
52
|
import '@sapphire/plugin-i18next/register';
|
|
49
53
|
```
|
|
50
54
|
|
|
55
|
+
The basic structure of a translation file is as follows:
|
|
56
|
+
|
|
57
|
+
```jsonc
|
|
58
|
+
// languages/en-US/commands/ping.json
|
|
59
|
+
{
|
|
60
|
+
"success": "Pong!",
|
|
61
|
+
"success_with_args": "Pong! Took me {{latency}}ms to reply"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { resolveKey } from '@sapphire/plugin-i18next';
|
|
69
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
70
|
+
import type { Message } from 'discord.js';
|
|
71
|
+
|
|
72
|
+
export class PingCommand extends Command {
|
|
73
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
74
|
+
super(context, {
|
|
75
|
+
...options,
|
|
76
|
+
description: 'ping pong'
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public async run(message: Message) {
|
|
81
|
+
await message.channel.send(await resolveKey('commands/ping:success'))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`sendLocalized` will send translated text resolved from a key to a specified channel.
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { sendLocalized } from '@sapphire/plugin-i18next'
|
|
90
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
91
|
+
|
|
92
|
+
import type { Message } from 'discord.js';
|
|
93
|
+
|
|
94
|
+
export class PingCommand extends Command {
|
|
95
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
96
|
+
super(context, {
|
|
97
|
+
...options,
|
|
98
|
+
description: 'ping pong'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public async run(message: Message) {
|
|
103
|
+
await sendLocalized(message, 'commands/ping:success')
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`editLocalized` edits a message, replacing its content with translated text resolved from its key.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { editLocalized } from '@sapphire/plugin-i18next'
|
|
112
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
113
|
+
|
|
114
|
+
import type { Message } from 'discord.js';
|
|
115
|
+
|
|
116
|
+
export class PingCommand extends Command {
|
|
117
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
118
|
+
super(context, {
|
|
119
|
+
...options,
|
|
120
|
+
description: 'ping pong'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public async run(message: Message) {
|
|
125
|
+
await editLocalized(message, 'commands/ping:success_args', { latency: ws.ping })
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`fetchLanguage` returns the guild-specific language that the client is using.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { fetchLanguage } from '@sapphire/plugin-i18next'
|
|
134
|
+
import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
|
|
135
|
+
|
|
136
|
+
import type { Message } from 'discord.js';
|
|
137
|
+
|
|
138
|
+
export class PingCommand extends Command {
|
|
139
|
+
public constructor(context: PieceContext, options: CommandOptions) {
|
|
140
|
+
super(context, {
|
|
141
|
+
...options,
|
|
142
|
+
description: 'ping pong'
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public async run(message: Message) {
|
|
147
|
+
return message.channel.send(await fetchLanguage(message));
|
|
148
|
+
// ===> en-US
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
51
153
|
## Sapphire i18next Documentation
|
|
52
154
|
|
|
53
155
|
For the full @sapphire/plugin-i18next documentation please refer to the TypeDoc generated [documentation](https://sapphiredev.github.io/plugins/modules/_sapphire_plugin_i18next.html).
|
|
@@ -86,6 +188,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
86
188
|
<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>
|
|
87
189
|
<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
190
|
<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>
|
|
191
|
+
<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>
|
|
89
192
|
</tr>
|
|
90
193
|
</table>
|
|
91
194
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternationalizationHandler.d.ts","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAc,aAAa,EAAE,MAAM,qBAAqB,CAAC;A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AAS;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;IAexD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACI,aAAa,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAc;IAEpG;;;OAGG;IACU,IAAI;IA6BjB;;;;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,14 @@ class InternationalizationHandler {
|
|
|
123
123
|
writable: true,
|
|
124
124
|
value: () => null
|
|
125
125
|
});
|
|
126
|
-
this.options = options ?? {};
|
|
127
|
-
this.languagesDirectory = this.options.defaultLanguageDirectory ?? path_1.join(pieces_1.getRootData().root, 'languages');
|
|
126
|
+
this.options = options ?? { i18next: { ignoreJSONStructure: false } };
|
|
127
|
+
this.languagesDirectory = this.options.defaultLanguageDirectory ?? (0, path_1.join)((0, pieces_1.getRootData)().root, 'languages');
|
|
128
128
|
this.backendOptions = {
|
|
129
|
-
loadPath: path_1.join(this.languagesDirectory, '{{lng}}', '{{ns}}.json'),
|
|
129
|
+
loadPath: (0, path_1.join)(this.languagesDirectory, '{{lng}}', '{{ns}}.json'),
|
|
130
130
|
addPath: this.languagesDirectory,
|
|
131
131
|
...this.options.backend
|
|
132
132
|
};
|
|
133
|
-
if (utilities_1.isFunction(this.options.fetchLanguage)) {
|
|
133
|
+
if ((0, utilities_1.isFunction)(this.options.fetchLanguage)) {
|
|
134
134
|
this.fetchLanguage = this.options.fetchLanguage;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -140,7 +140,8 @@ class InternationalizationHandler {
|
|
|
140
140
|
*/
|
|
141
141
|
async init() {
|
|
142
142
|
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;
|
|
143
|
+
const userOptions = (0, utilities_1.isFunction)(this.options.i18next) ? this.options.i18next(namespaces, languages) : this.options.i18next;
|
|
144
|
+
const ignoreJSONStructure = userOptions?.ignoreJSONStructure ?? false;
|
|
144
145
|
i18next_1.default.use(i18next_fs_backend_1.default);
|
|
145
146
|
await i18next_1.default.init({
|
|
146
147
|
backend: this.backendOptions,
|
|
@@ -154,7 +155,8 @@ class InternationalizationHandler {
|
|
|
154
155
|
defaultNS: 'default',
|
|
155
156
|
ns: namespaces,
|
|
156
157
|
preload: languages,
|
|
157
|
-
...userOptions
|
|
158
|
+
...userOptions,
|
|
159
|
+
ignoreJSONStructure
|
|
158
160
|
});
|
|
159
161
|
this.namespaces = new Set(namespaces);
|
|
160
162
|
for (const item of languages) {
|
|
@@ -203,7 +205,7 @@ class InternationalizationHandler {
|
|
|
203
205
|
* @since 1.0.0
|
|
204
206
|
*/
|
|
205
207
|
async walkLanguageDirectory(dir, namespaces = [], current = '') {
|
|
206
|
-
const directory = await promises_1.opendir(dir);
|
|
208
|
+
const directory = await (0, promises_1.opendir)(dir);
|
|
207
209
|
const languages = [];
|
|
208
210
|
for await (const entry of directory) {
|
|
209
211
|
const fn = entry.name;
|
|
@@ -213,7 +215,7 @@ class InternationalizationHandler {
|
|
|
213
215
|
const isLanguage = fn.includes('-');
|
|
214
216
|
if (isLanguage)
|
|
215
217
|
languages.push(fn);
|
|
216
|
-
({ namespaces } = await this.walkLanguageDirectory(path_1.join(dir, fn), namespaces, isLanguage ? '' : `${fn}/`));
|
|
218
|
+
({ namespaces } = await this.walkLanguageDirectory((0, path_1.join)(dir, fn), namespaces, isLanguage ? '' : `${fn}/`));
|
|
217
219
|
}
|
|
218
220
|
else if (entry.name.endsWith('.json')) {
|
|
219
221
|
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,6CAA+C;AAC/C,mDAAyE;AACzE,0CAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"InternationalizationHandler.js","sourceRoot":"","sources":["../../src/lib/InternationalizationHandler.ts"],"names":[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BACpC,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;AApMD,kEAoMC"}
|
package/dist/lib/functions.d.ts
CHANGED
|
@@ -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
|
*/
|
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 +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D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/plugin-i18next",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.d810c56.0",
|
|
4
4
|
"description": "Plugin for @sapphire/framework to support i18next.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@sapphire/utilities": "^2.0.1",
|
|
38
38
|
"@types/i18next-fs-backend": "^1.0.1",
|
|
39
|
-
"i18next": "^
|
|
39
|
+
"i18next": "^20.6.1",
|
|
40
40
|
"i18next-fs-backend": "^1.1.1",
|
|
41
41
|
"tslib": "^2.3.1"
|
|
42
42
|
},
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "d810c56b926526391b68269842a98aef7cb59d17"
|
|
76
76
|
}
|