add i18n for console logs

This commit is contained in:
ari melody 2025-07-13 20:44:54 +01:00
parent b170a532f6
commit 7752585488
Signed by: ari
GPG key ID: CF99829C92678188
14 changed files with 77 additions and 31 deletions

View file

@ -28,7 +28,7 @@
if (!data) return;
account.set(parseAccount(data));
console.log(`Logged in as ${$account.fqn}`);
console.log(lang.string('logs.logged_in', $account.fqn));
// spin up async task to fetch notifications
const notif_data = await api.getNotifications(

View file

@ -14,7 +14,7 @@
if (account) getTimeline();
});
document.addEventListener("scroll", () => {
document.addEventListener('scroll', () => {
if ($account && $page.url.pathname !== "/") return;
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
getTimeline();

View file

@ -33,16 +33,16 @@
// TODO: make `server` a key/value pair to support multiple servers
server.set(await createServer(data.server_host));
if (!$server) {
error = `Failed to connect to <code>${data.server_host}</code>.`;
console.error(`Failed to connect to ${data.server_host}.`);
error = lang.string('error.connection_failed', data.server_host);
console.error(lang.string('logs.connection_failed', data.server_host));
return;
}
}
const post_data = await api.getPost($server.host, token, post_id);
if (!post_data || post_data.error) {
error = `Failed to retrieve post <code>${post_id}</code>.`;
console.error(`Failed to retrieve post ${post_id}.`);
error = lang.string('error.post_fetch_failed', post_id);
console.error(lang.string('logs.post_fetch_failed', post_id));
return;
}
let post = await parsePost(post_data, 0);
@ -83,9 +83,9 @@
<Button centered on:click={() => {goto(previous_page)}}>{lang.string('navigation.back')}</Button>
</nav>
{/if}
<img src={post.account.avatar_url} type={post.account.avatar_type || "image/png"} alt="" width="40" height="40" class="header-avatar" loading="lazy" decoding="async">
<img src={post.account.avatar_url} type={post.account.avatar_type || 'image/png'} alt="" width="40" height="40" class="header-avatar" loading="lazy" decoding="async">
<h1>
{@html lang.string('post.by').replaceAll('%1', post.account.rich_name)}
{@html lang.string('post.by', post.account.rich_name)}
</h1>
</header>

View file

@ -8,17 +8,20 @@
import { error } from '@sveltejs/kit';
import { unread_notif_count, last_read_notif_id } from '$lib/notifications.js';
import { account } from '$lib/stores/account.js';
import Lang from '$lib/lang';
export let data;
const lang = Lang('en_GB');
let auth_code = data.code;
if (!auth_code || !get(server) || !get(app)) {
error(400, { message: "Bad request" });
error(400, { message: lang.string('error.bad_request') });
} else {
api.getToken(get(server).host, get(app).id, get(app).secret, auth_code).then(token => {
if (!token) {
error(400, { message: "Invalid auth code provided" });
error(400, { message: lang.string('error.invalid_auth_code') });
}
app.update(app => {
@ -30,7 +33,7 @@
if (!data) return goto("/");
account.set(parseAccount(data));
console.log(`Logged in as ${get(account).fqn}`);
console.log(lang.string('logs.logged_in', get(account).fqn));
// spin up async task to fetch notifications
return api.getNotifications(