Merge pull request 'ga_IE Localisation, other localisation touchups' (#2) from Catster/campfire:design-v2 into design-v2

Reviewed-on: https://codeberg.org/arimelody/campfire/pulls/2
This commit is contained in:
ari melody 2025-07-14 20:58:20 +02:00
commit 8e9fb6598e
6 changed files with 178 additions and 15 deletions

View file

@ -1,4 +1,5 @@
import * as en_GB from '@cf/lang/en_GB.json';
import * as ga_IE from '@cf/lang/ga_IE.json';
/**
* @param {string} lang IETH language tag (i.e. en_GB)
@ -36,7 +37,7 @@ export default function init(lang) {
i++;
token = tokens[i];
}
i = 1;
while (true) {
if (args.length < i || !res.includes('%' + i))

View file

@ -2,12 +2,12 @@ import Lang from '$lib/lang';
const lang = Lang('en_GB');
const denoms = [
{ unit: 's', min: 0 },
{ unit: 'm', min: 60 },
{ unit: 'h', min: 60 },
{ unit: 'd', min: 24 },
{ unit: 'w', min: 7 },
{ unit: 'y', min: 52 },
{ unit: lang.string('time.second'), min: 0 },
{ unit: lang.string('time.minute'), min: 60 },
{ unit: lang.string('time.hour'), min: 60 },
{ unit: lang.string('time.day'), min: 24 },
{ unit: lang.string('time.week'), min: 7 },
{ unit: lang.string('time.year'), min: 52 },
];
export function shorthand(date) {
@ -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 "in " + Math.floor(value) + unit;
return lang.string('time.ago').replaceAll('%1', Math.floor(value) + unit);
return lang.string('time.in').replaceAll('%1', Math.floor(value) + unit);
}

View file

@ -29,6 +29,7 @@
// let media_ids = [];
let show_cw = false;
let visibility = "Public";
let visibilityLocale = lang.string('post.visibility.public');
const placeholders = lang.stringArray('compose_placeholders');
let placeholder = Array.isArray(placeholders) ? placeholders[Math.floor(placeholders.length * Math.random())]
@ -74,15 +75,19 @@
switch (visibility) {
case "Public":
visibility = "Unlisted";
visibilityLocale = lang.string('post.visibility.unlisted');
break;
case "Unlisted":
visibility = "Followers only";
visibilityLocale = lang.string('post.visibility.follow_only');
break;
case "Followers only":
visibility = "Private";
visibilityLocale = lang.string('post.visibility.private');
break;
case "Private":
visibility = "Public";
visibilityLocale = lang.string('post.visibility.public');
break;
}
}
@ -102,7 +107,7 @@
<div class="composer-info" on:mouseup|stopPropagation>
</div>
</header>
<div title={visibility}>
<div title={visibilityLocale}>
<Button centered={true} on:click={() => {cycleVisibility()}}>
<svelte:fragment slot="icon">
<!-- TODO: this should be a drop-down option!...later -->
@ -120,7 +125,7 @@
</div>
</div>
{#if show_cw}
<input type="text" id="" placeholder="Content warning" bind:value={content_warning}/>
<input type="text" id="" placeholder="{lang.string('post.warning.placeholder')}" bind:value={content_warning}/>
{/if}
<textarea placeholder="{placeholder}" class="textbox" bind:value={content}></textarea>
<div class="composer-footer">

View file

@ -24,7 +24,7 @@
<span class="post-context-time">
<time title="{time_string}">{short_time(post.created_at)}</time>
{#if post.visibility !== "public"}
<span class="post-visibility">- {post.visibility}</span>
<span class="post-visibility">- {lang.string(`post.visibility.${post.visibility}`)}</span>
{/if}
</span>
</div>