Skip to content

Commit 3dda610

Browse files
committed
chore: more translations
1 parent a6b24fb commit 3dda610

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

lang/en/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
],
6464
"fishday": "Disable April Fools Jokes",
6565
"fishday.note": "Disables *almost* everything.",
66+
"friend.add": "Add friends without refreshing",
6667
"friend.auto": "Disable",
6768
"friend.auto.ignore": "Include ignored chat users",
6869
"friend.auto.silent": "Silent",

lang/en/toast.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,27 @@
55
"custom.ban.user": "'$1' has been banned from custom match!",
66
"custom.enter": "You can now press enter on the Create Game window.",
77
"dismiss": "Dismiss",
8+
"friend.delete": "Friends list will be updated upon refresh.",
9+
"friend.delete.failed": "Failed to remove: $1",
810
"friend.request": "Pending Friend Request",
911
"friend.request.accept": "Accepted friend request from: $1",
1012
"friend.request.auto": "Auto declined friend request from: $1",
1113
"friend.request.decline": "Declined friend request from: $1",
14+
"friend.request.failed": "{{STYLE:red|Failed to send friend request to $1}}",
15+
"friend.request.sent": "{{STYLE:green|Sent friend request to $1}}",
1216
"friendship": "Claimed Friendship Rewards",
1317
"friendship.notification": "Pending Friendship Rewards",
1418
"ignore": "You've ignored $1",
15-
"info": "Did you know?",
1619
"ignore.info": "You can right click users in chat to display user options!",
20+
"info": "Did you know?",
21+
"login": "Try logging back in",
1722
"menu": "UnderScript has a menu, press ESC to open it!",
1823
"new.bundle": "New Bundle Available",
1924
"new.card": "{{PLURAL:$1|New Card|New Cards}}",
2025
"new.emotes": "New Emotes Available",
2126
"new.pass": "New Quest Pass",
2227
"new.skins": "New Skins or Avatars",
28+
"note": "Please note:",
2329
"patch.notes": "[UnderScript] Patch Notes",
2430
"ping": "UnderScript has custom notifications! You can change them however you like.",
2531
"ping.remove": "Remove @underscript!",

src/base/friends/add.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import { toast } from 'src/utils/2.toasts.js';
55
import onPage from 'src/utils/onPage.js';
66
import decrypt from 'src/utils/decrypt.emails.js';
77
import * as $el from 'src/utils/elementHelper.js';
8+
import Translation from 'src/structures/constants/translation';
9+
import style from 'src/utils/style';
810

911
const setting = settings.register({
10-
// TODO: translation
11-
name: 'Add friends without refreshing',
12+
name: Translation.Setting('friend.add'),
1213
key: 'underscript.friend.add',
1314
default: true,
1415
page: 'Friends',
@@ -17,6 +18,9 @@ const setting = settings.register({
1718
onPage('Friends', function addFriend() {
1819
const single = true;
1920
const input = document.querySelector('input[name="username"]');
21+
const sent = Translation.Toast('friend.request.sent');
22+
const failed = Translation.Toast('friend.request.failed');
23+
style.add('.green { color: green; }');
2024

2125
function submit() {
2226
if (typeof URLSearchParams === 'undefined' || !setting.value()) return undefined;
@@ -32,10 +36,8 @@ onPage('Friends', function addFriend() {
3236
const result = page.querySelector('form[action="Friends"] + p');
3337
if (result) {
3438
const success = result.classList.contains('green');
35-
toast({
36-
// TODO: translation
37-
text: `<p style="color: ${success ? 'green' : 'red'}">${success ? 'Sent' : 'Failed to send'} friend request to ${name}</p>`,
38-
});
39+
const text = success ? sent : failed;
40+
toast(text.withArgs(name));
3941
if (success) {
4042
const element = $el.text.contains(decrypt(page).querySelectorAll('a[href^="Friends?delete="]'), `${name} LV`, { mutex, single });
4143
$el.text.contains(document.querySelectorAll('p'), 'Pending requests', { single }).parentElement.append(element);

src/base/friends/delete.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const setting = settings.register({
1616
});
1717

1818
let reminded = false;
19+
const failed = Translation.Toast('friend.delete.failed', 1);
1920

2021
function remove(e) {
2122
if (!setting.value()) return;
@@ -30,21 +31,19 @@ function process(btn) {
3031
axios.get(link).then((response) => {
3132
const onlineFriends = $(response.data).find(`#onlineFriends`);
3233
if (!onlineFriends.length) {
33-
// TODO: translation
34-
errorToast('Try logging back in');
34+
errorToast(Translation.Toast('login'));
3535
return;
3636
}
3737
const found = decrypt(onlineFriends).find(`a[href="${link}"]`);
3838
if (found.length) {
39-
// TODO: translation
40-
toast(`Failed to remove: ${found.parent().find('span:nth-child(3)').text()}`);
39+
const name = found.parent().find('span:nth-child(3)').text();
40+
toast(failed.withArgs(name));
4141
btn.appendTo(parent);
4242
} else {
4343
if (!reminded) {
4444
toast({
45-
// TODO: translation
46-
title: 'Please note:',
47-
text: 'Friends list will be updated upon refresh.',
45+
title: Translation.Toast('note'),
46+
text: Translation.Toast('friend.delete'),
4847
});
4948
reminded = true;
5049
}

0 commit comments

Comments
 (0)