Skip to content

Commit 1e4c1a1

Browse files
committed
chore: more translations
1 parent f94f9e6 commit 1e4c1a1

File tree

10 files changed

+44
-21
lines changed

10 files changed

+44
-21
lines changed

lang/en/chat.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

lang/en/general.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"deck.average": "Average gold cost",
3+
"passive": "Passive",
4+
"reconnecting": "Reconnecting..."
5+
}

lang/en/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
"category.chat.commands": "Commands",
1212
"category.chat.emotes": "Emotes",
1313
"category.chat.ignored": "Ignored Users",
14+
"category.chat.import": "Import",
1415
"category.chat.links": "Trusted Domains",
1516
"category.chat.ping": "Ping Me",
1617
"category.streamer": "Streamer Mode",
1718
"category.home": "Home",
1819
"category.library.crafting": "Crafting",
20+
"deck.average": "Disable deck average counter",
21+
"deck.preview": "Disable Deck Preview",
1922
"disable.border": "Disable Crafting Highlight",
2023
"disable.broadcast": "Disable Broadcast Toast",
2124
"disable.command": "Disable $1 command",
@@ -28,13 +31,15 @@
2831
"disable.links": "Use Original Link Detection",
2932
"disable.ping": "Disable Chat Ping {{STYLE:highlight|(highlighting)}}",
3033
"ignoreChat": "Behavior",
34+
"import.shiny": "Prefer Shiny",
3135
"note.refresh": "Will require you to refresh the page.",
3236
"page.chat": "Chat",
3337
"page.library": "Library",
3438
"page.plugins": "Plugins",
3539
"ping.global": "Only open chats",
3640
"ping.on": "On",
3741
"ping.toast": "Enable ping toasts",
42+
"patches": "Disable Patch Notes",
3843
"safelink": "Enabled",
3944
"safelink.trust": "Trust $1",
4045
"streamer": "Enable?",

lang/en/toast.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"new.emotes": "New Emotes Available",
1111
"new.pass": "New Quest Pass",
1212
"new.skins": "New Skins or Avatars",
13+
"patch.notes": "[UnderScript] Patch Notes",
1314
"ping": "UnderScript has custom notifications! You can change them however you like.",
1415
"ping.remove": "Remove @underscript!",
1516
"ping.settings": "Open settings",

src/base/chat/trustedLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ eventManager.on('BootstrapDialog:show', (dialog) => {
4747
const host = cache.value;
4848
const after = dialog.options.buttons[0];
4949
dialog.options.buttons.unshift({
50-
label: TrustDomain.withArgs('safelink.trust'),
50+
label: TrustDomain.withArgs(host).translate(),
5151
cssClass: 'btn-danger',
5252
action(ref) {
5353
register(host);

src/base/library/deck/average.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import * as settings from 'src/utils/settings/index.js';
33
import { global } from 'src/utils/global.js';
44
import onPage from 'src/utils/onPage.js';
55
import * as hover from 'src/utils/hover.js';
6+
import Translation from 'src/structures/constants/translation';
67

78
const setting = settings.register({
8-
name: 'Disable deck average counter',
9+
name: Translation.Setting('disable.deck.average'),
910
key: 'underscript.disable.deck.average',
1011
refresh: onPage('Decks'),
1112
page: 'Library',
@@ -14,8 +15,9 @@ const setting = settings.register({
1415
// Calculate average
1516
eventManager.on(':preload:Decks', () => {
1617
if (setting.value()) return;
17-
const avg = $('<span>').hover(hover.show('Average gold cost'));
18-
$('#soulInfo span').after('<span>Passive</span> ', avg).remove();
18+
const label = $('<span>');
19+
const avg = $('<span>');
20+
$('#soulInfo span').after(label, ' ', avg).remove();
1921

2022
function round(amt, dec = 2) {
2123
return Number.parseFloat(amt).toFixed(dec);
@@ -29,4 +31,8 @@ eventManager.on(':preload:Decks', () => {
2931
}
3032

3133
eventManager.on('Deck:Soul Deck:Change Deck:Loaded', count);
34+
eventManager.on('underscript:ready', () => {
35+
label.text(Translation.General('passive').translate());
36+
avg.hover(hover.show(Translation.General('deck.average').translate()));
37+
});
3238
});

src/base/library/deck/import.shiny.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import eventManager from 'src/utils/eventManager.js';
22
import * as settings from 'src/utils/settings/index.js';
33
import { globalSet } from 'src/utils/global.js';
4+
import Translation from 'src/structures/constants/translation';
45

56
const setting = settings.register({
6-
name: 'Prefer Shiny',
7+
name: Translation.Setting('import.shiny'),
78
key: 'underscript.import.shiny',
89
default: true,
910
page: 'Library',
10-
category: 'Import',
11+
category: Translation.CATEGORY_CHAT_IMPORT,
1112
});
1213

1314
function override(idCard, list = []) {

src/base/library/deck/preview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import eventManager from 'src/utils/eventManager.js';
22
import * as settings from 'src/utils/settings/index.js';
33
import { globalSet } from 'src/utils/global.js';
44
import onPage from 'src/utils/onPage.js';
5+
import Translation from 'src/structures/constants/translation';
56

67
const setting = settings.register({
7-
name: 'Disable Deck Preview',
8+
name: Translation.Setting('disable.deck.preview'),
89
key: 'underscript.disable.deckPreview',
910
// hidden: typeof displayCardDeck === 'function',
1011
onChange(val, val2) {

src/base/streamer/0.streamer.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,25 @@ const mode = settings.register({
2626
}
2727
},
2828
type: 'select',
29-
category: 'Streamer Mode',
29+
category: Translation.CATEGORY_STREAMER,
3030
});
3131
const setting = settings.register({
3232
key: 'underscript.streaming',
3333
hidden: true,
3434
});
3535
api.register('streamerMode', streaming);
36+
const ON = Translation.Menu('streamer.on');
37+
const OFF = Translation.Menu('streamer.off');
3638
menu.addButton({
37-
text: () => `Streamer Mode: ${streaming() ? 'On' : 'Off'}`,
39+
text: () => (streaming() ? ON : OFF),
3840
hidden: () => mode.value() === disabled,
3941
action: () => update(!streaming()),
4042
});
4143
eventManager.on(':preload', alert);
4244

4345
function alert() {
4446
if (!streaming() || mode.value() === silent) return;
45-
toast('Streamer Mode Active');
47+
toast(Translation.Toast('streamer'));
4648
}
4749

4850
function update(value) {

src/structures/constants/translation.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type TranslationWithArgsOptions<N extends number> = TranslationOptions &
99

1010
export type TranslationOptions = {
1111
args?: string[];
12+
fallback?: string;
1213
prefix?: string | null;
1314
};
1415

@@ -43,25 +44,27 @@ export interface TranslationWithArgs<N extends number> extends TranslationBase {
4344
}
4445

4546
export default class Translation extends Constant implements TranslationBase {
46-
static RECONNECTING = this.Chat('reconnecting');
47-
4847
static CATEGORY_CHAT_COMMAND = this.Setting('category.chat.commands');
4948
static CATEGORY_CHAT_IGNORED = this.Setting('category.chat.ignored');
49+
static CATEGORY_CHAT_IMPORT = this.Setting('category.chat.import');
5050
static CATEGORY_HOME = this.Setting('category.home');
5151
static CATEGORY_LIBRARY_CRAFTING = this.Setting('category.library.crafting');
52+
static CATEGORY_STREAMER = this.Setting('category.streamer');
5253

5354
static DISABLE_COMMAND_SETTING = this.Setting('disable.command', 1);
5455

5556
static DISMISS = this.Toast('dismiss');
5657
static IGNORE = this.Toast('ignore', 1);
57-
static UNDO = this.Toast('undo');
58+
static UNDO = new Translation('toast.undo', { fallback: 'Undo' });
5859

5960
static CLOSE = this.Vanilla('dialog-close');
6061

6162
private args: string[];
63+
private fallback?: string;
6264

6365
constructor(key: string, {
6466
args = [],
67+
fallback,
6568
prefix = 'underscript',
6669
}: TranslationOptions = {}) {
6770
if (prefix) {
@@ -70,6 +73,7 @@ export default class Translation extends Constant implements TranslationBase {
7073
super(key);
7174
}
7275
this.args = args;
76+
this.fallback = fallback;
7377
}
7478

7579
get key(): string {
@@ -79,6 +83,7 @@ export default class Translation extends Constant implements TranslationBase {
7983
translate(...args: string[]): string {
8084
return translateText(this.key, {
8185
args: args.length ? args : this.args,
86+
fallback: this.fallback,
8287
});
8388
}
8489

@@ -93,12 +98,12 @@ export default class Translation extends Constant implements TranslationBase {
9398
return this.translate();
9499
}
95100

96-
static Chat(key: string): Translation;
97-
static Chat<N extends number>(key: string, hasArgs: N): TranslationWithArgs<N>;
98-
static Chat<N extends number>(key: string, ...args: Tuple<string, N>): TranslationWithArgs<N>;
99-
static Chat<N extends number>(key: string, hasArgs?: string | N, ...rest: string[]): TranslationBase | TranslationWithArgs<N> {
101+
static General(key: string): Translation;
102+
static General<N extends number>(key: string, hasArgs: N): TranslationWithArgs<N>;
103+
static General<N extends number>(key: string, ...args: Tuple<string, N>): TranslationWithArgs<N>;
104+
static General<N extends number>(key: string, hasArgs?: string | N, ...rest: string[]): TranslationBase | TranslationWithArgs<N> {
100105
const args = typeof hasArgs === 'string' ? [hasArgs, ...rest] : rest;
101-
return new Translation(`chat.${key}`, { args });
106+
return new Translation(`general.${key}`, { args });
102107
}
103108

104109
static Menu(key: string): Translation;

0 commit comments

Comments
 (0)