diff --git a/src/lang/en_GB.json b/src/lang/en_GB.json
index 65379a8..0f80eb4 100644
--- a/src/lang/en_GB.json
+++ b/src/lang/en_GB.json
@@ -1,10 +1,10 @@
{
"compose_placeholders": [
- "What's cooking, %1?",
+ "What's cooking, $1?",
"Speak your mind!",
"Federate something...",
"I sure love posting!",
- "Another day, another %1 post!"
+ "Another day, another $1 post!"
],
"login": {
@@ -84,29 +84,6 @@
}
},
- "logs": {
- "logged_in": "Logged in as %1",
- "server_detected": "Server detected as %1 (%2) with capabilities: {%3}}",
- "server_unsupported": "Server %1 is unsupported (%2). Things may break, or not work as expected",
- "no_hostname": "Attempted to connect to a server without providing a hostname",
- "no_https": "Cowardly refusing to connect to an insecure server",
- "connection_failed": "Failed to connect to %1",
- "post_fetch_failed": "Failed to fetch post %1",
- "post_parse_failed": "Failed to parse post",
- "post_parse_failed_id": "Failed to parse post %1",
- "token_revoke_failed": "Token revocation failed! Dumping data anyways",
- "sound_does_not_exist": "Attempted to play sound \"%1\", which does not exist!",
- "account_data_empty": "Attempted to parse account data but no data was provided",
- "timeline_fetch_failed": "Failed to retrieve timeline."
- },
-
- "error": {
- "bad_request": "Bad request",
- "invalid_auth_code": "Invalid auth code provided",
- "connection_failed": "Failed to connect to %1
.",
- "post_fetch_failed": "Failed to retrieve post %1
."
- },
-
"compose": "Post",
"search": "Search",
"loading": "just a moment...",
diff --git a/src/lib/account.js b/src/lib/account.js
index 394fe0f..7bfd696 100644
--- a/src/lib/account.js
+++ b/src/lib/account.js
@@ -1,9 +1,6 @@
import { server } from '$lib/client/server.js';
import { parseEmoji, renderEmoji } from '$lib/emoji.js';
import { get, writable } from 'svelte/store';
-import Lang from '$lib/lang';
-
-const lang = Lang('en_GB');
const cache = writable({});
@@ -14,7 +11,7 @@ const cache = writable({});
*/
export function parseAccount(data) {
if (!data) {
- console.error(lang.string('logs.account_data_empty'));
+ console.error("Attempted to parse account data but no data was provided");
return null;
}
let account = get(cache)[data.id];
@@ -23,7 +20,7 @@ export function parseAccount(data) {
account = {};
account.id = data.id;
- account.nickname = data.display_name.trim().replaceAll('<', '<').replaceAll('>', '>');
+ account.nickname = data.display_name.trim();
account.username = data.username;
account.name = account.nickname || account.username;
account.avatar_url = data.avatar;
@@ -34,8 +31,6 @@ export function parseAccount(data) {
else
account.host = get(server).host;
- account.fqn = data.fqn || account.username + account.host;
-
account.mention = "@" + account.username;
if (account.host != get(server).host)
account.mention += "@" + account.host;
diff --git a/src/lib/client/server.js b/src/lib/client/server.js
index 3c85647..6b42ffe 100644
--- a/src/lib/client/server.js
+++ b/src/lib/client/server.js
@@ -35,11 +35,11 @@ server.subscribe(server => {
*/
export async function createServer(host) {
if (!host) {
- console.error(lang.string('logs.no_hostname'));
+ console.error("Attempted to create server without providing a hostname");
return false;
}
if (host.startsWith("http://")) {
- console.error(lang.string('logs.no_https'));
+ console.error("Cowardly refusing to connect to an insecure server");
return false;
}
@@ -49,7 +49,7 @@ export async function createServer(host) {
if (host.startsWith("https://")) host = host.substring(8);
const data = await api.getInstance(host);
if (!data) {
- console.error(lang.string('logs.connection_failed', host));
+ console.error(`Failed to connect to ${host}`);
return false;
}
@@ -58,9 +58,9 @@ export async function createServer(host) {
server.capabilities = getCapabilities(server.type);
if (server.type === server_types.UNSUPPORTED) {
- console.warn(lang.string('logs.server_unsupported', host, server.version));
+ console.warn(`Server ${host} is unsupported (${server.version}). Things may break, or not work as expected`);
} else {
- console.log(lang.string('logs.server_detected', server.type, server.version, server.capabilities.join(', ')));
+ console.log(`Server detected as "${server.type}" (${server.version}) with capabilities: {${server.capabilities.join(', ')}}`);
}
return server;
diff --git a/src/lib/lang.js b/src/lib/lang.js
index 955a749..8e90901 100644
--- a/src/lib/lang.js
+++ b/src/lib/lang.js
@@ -19,7 +19,7 @@ export default function init(lang) {
i18n.lang = language;
i18n.lang_code = lang;
- i18n.string = function(/* @type string */ key, ...args) {
+ i18n.string = function(/* @type string */ key) {
const tokens = key.split('.');
let i = 0;
@@ -32,20 +32,10 @@ export default function init(lang) {
return key;
}
if (typeof res === 'string' || res instanceof String)
- break;
+ return res;
i++;
token = tokens[i];
}
-
- i = 1;
- while (true) {
- if (args.length < i || !res.includes('%' + i))
- break;
- res = res.replaceAll('%' + i, args[i - 1]);
- i++;
- }
-
- return res;
}
i18n.stringArray = function(/* @type string */ key) {
const tokens = key.split('.');
diff --git a/src/lib/sound.js b/src/lib/sound.js
index 9c94547..377b833 100644
--- a/src/lib/sound.js
+++ b/src/lib/sound.js
@@ -1,7 +1,3 @@
-import Lang from '$lib/lang';
-
-const lang = Lang('en_GB');
-
import sound_log from '../sound/log.ogg';
import sound_hello from '../sound/hello.ogg';
import sound_success from '../sound/success.ogg';
@@ -20,7 +16,7 @@ export function playSound(name) {
if (!name) name = "default";
const sound = sounds[name];
if (!sound) {
- console.warn(lang.string('lang.sound_does_not_exist', name));
+ console.warn(`Attempted to play sound "${name}", which does not exist!`);
return;
}
sound.pause();
diff --git a/src/lib/time.js b/src/lib/time.js
index 99811bf..9a1c4eb 100644
--- a/src/lib/time.js
+++ b/src/lib/time.js
@@ -21,6 +21,6 @@ export function shorthand(date) {
unit = denoms[index].unit;
}
if (value > 0)
- return lang.string('post.time', Math.floor(value) + unit);
+ return lang.string('post.time').replaceAll('%1', Math.floor(value) + unit);
return "in " + Math.floor(value) + unit;
}
diff --git a/src/lib/timeline.js b/src/lib/timeline.js
index 03e5052..ae8a5e3 100644
--- a/src/lib/timeline.js
+++ b/src/lib/timeline.js
@@ -3,12 +3,9 @@ import { server } from '$lib/client/server.js';
import { app } from '$lib/client/app.js';
import { get, writable } from 'svelte/store';
import { parsePost } from '$lib/post.js';
-import Lang from '$lib/lang';
export const timeline = writable([]);
-const lang = Lang('en_GB');
-
let loading = false;
export async function getTimeline(clean) {
@@ -27,7 +24,7 @@ export async function getTimeline(clean) {
);
if (!timeline_data) {
- console.error(lang.string('logs.timeline_fetch_failed'));
+ console.error(`Failed to retrieve timeline.`);
loading = false;
return;
}
@@ -40,10 +37,10 @@ export async function getTimeline(clean) {
if (!post) {
if (post === null || post === undefined) {
if (post_data.id) {
- console.warn(lang.string('logs.post_parse_failed_id', post_data.id));
+ console.warn("Failed to parse post #" + post_data.id);
} else {
- console.warn(lang.string('logs.post_parse_failed'));
- console.debug(post_data);
+ console.warn("Failed to parse post:");
+ console.warn(post_data);
}
}
continue;
diff --git a/src/lib/ui/Composer.svelte b/src/lib/ui/Composer.svelte
index 7859a7e..2d5d231 100644
--- a/src/lib/ui/Composer.svelte
+++ b/src/lib/ui/Composer.svelte
@@ -32,7 +32,7 @@
const placeholders = lang.stringArray('compose_placeholders');
let placeholder = Array.isArray(placeholders) ? placeholders[Math.floor(placeholders.length * Math.random())]
- .replaceAll("%1", $account.username) : placeholders;
+ .replaceAll("$1", $account.username) : placeholders;
const dispatch = createEventDispatcher();
diff --git a/src/lib/ui/Navigation.svelte b/src/lib/ui/Navigation.svelte
index 96f4879..e977153 100644
--- a/src/lib/ui/Navigation.svelte
+++ b/src/lib/ui/Navigation.svelte
@@ -72,7 +72,7 @@
);
if (!res.ok)
- console.warn(lang.string('logs.token_revoke_failed'));
+ console.warn("Token revocation failed! Dumping data anyways");
account.set(false);
app.set(false);
@@ -175,7 +175,7 @@
${data.server_host}
.`;
+ console.error(`Failed to connect to ${data.server_host}.`);
return;
}
}
const post_data = await api.getPost($server.host, token, post_id);
if (!post_data || post_data.error) {
- error = lang.string('error.post_fetch_failed', post_id);
- console.error(lang.string('logs.post_fetch_failed', post_id));
+ error = `Failed to retrieve post ${post_id}
.`;
+ console.error(`Failed to retrieve post ${post_id}.`);
return;
}
let post = await parsePost(post_data, 0);
@@ -83,9 +83,9 @@
{/if}
-