Skip to content

Commit 83f35b0

Browse files
committed
feat: vanilla translations
1 parent d494b19 commit 83f35b0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/structures/constants/translation.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export default class Translation extends Constant implements TranslationBase {
5454
static IGNORE = this.Toast('ignore', 1);
5555
static UNDO = this.Toast('undo');
5656

57+
static CLOSE = this.Vanilla('dialog-close');
58+
5759
private args: string[];
5860

5961
constructor(key: string, {
@@ -120,4 +122,12 @@ export default class Translation extends Constant implements TranslationBase {
120122
const args = typeof hasArgs === 'string' ? [hasArgs, ...rest] : rest;
121123
return new Translation(`toast.${key}`, { args });
122124
}
125+
126+
static Vanilla(key: string): Translation;
127+
static Vanilla<N extends number>(key: string, hasArgs: N): TranslationWithArgs<N>;
128+
static Vanilla<N extends number>(key: string, ...args: Tuple<string, N>): TranslationWithArgs<N>;
129+
static Vanilla<N extends number>(key: string, hasArgs?: string | N, ...rest: string[]): TranslationBase | TranslationWithArgs<N> {
130+
const args = typeof hasArgs === 'string' ? [hasArgs, ...rest] : rest;
131+
return new Translation(key, { args, prefix: null });
132+
}
123133
}

src/utils/DialogHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Translation from 'src/structures/constants/translation';
12
import eventEmitter from './eventEmitter.js';
23

34
export default class DialogHelper {
@@ -25,8 +26,7 @@ export default class DialogHelper {
2526
...buttons,
2627
{
2728
cssClass: 'btn-primary',
28-
// TODO: Translate
29-
label: 'Close',
29+
label: Translation.CLOSE.translate(),
3030
action: () => this.close(),
3131
},
3232
],

0 commit comments

Comments
 (0)