2
0
forked from jmug/cactoide

fix: outsorce user facing messages to json file

This commit is contained in:
Levente Orban
2025-11-07 14:01:47 +01:00
parent 1faa45e76b
commit 73c92b800a
2 changed files with 44 additions and 15 deletions

View File

@@ -251,6 +251,21 @@
"noEventsFoundTitle": "No events found", "noEventsFoundTitle": "No events found",
"noEventsFoundDescription": "Try adjusting your search terms or browse all events" "noEventsFoundDescription": "Try adjusting your search terms or browse all events"
}, },
"instance": {
"name": "Name",
"url": "URL",
"events": "Events",
"healthStatus": "Health Status",
"responseTime": "Response Time",
"notAvailable": "N/A",
"healthStatusHealthy": "healthy",
"healthStatusUnhealthy": "unhealthy",
"healthStatusUnknown": "unknown",
"description": "These are the instances that are part of the github original federation list, if you want to add your instance to the list, please open a pull request to the",
"configFile": "federation.config.js",
"file": "file.",
"noInstances": "No federation instances configured."
},
"calendar": { "calendar": {
"addToCalendarTitle": "Add to Calendar", "addToCalendarTitle": "Add to Calendar",
"googleCalendarTitle": "Google Calendar", "googleCalendarTitle": "Google Calendar",

View File

@@ -1,4 +1,6 @@
<script lang="ts"> <script lang="ts">
import { t } from '$lib/i18n/i18n.js';
interface InstanceData { interface InstanceData {
url: string; url: string;
name: string | null; name: string | null;
@@ -22,9 +24,20 @@
} }
function formatResponseTime(responseTime: number | null): string { function formatResponseTime(responseTime: number | null): string {
if (responseTime === null) return 'N/A'; if (responseTime === null) return t('instance.notAvailable');
return `${responseTime} ms`; return `${responseTime} ms`;
} }
function getHealthStatusText(status: 'healthy' | 'unhealthy' | 'unknown'): string {
switch (status) {
case 'healthy':
return t('instance.healthStatusHealthy');
case 'unhealthy':
return t('instance.healthStatusUnhealthy');
case 'unknown':
return t('instance.healthStatusUnknown');
}
}
</script> </script>
<div class="container mx-auto px-4 py-16 text-white"> <div class="container mx-auto px-4 py-16 text-white">
@@ -35,27 +48,27 @@
<th <th
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase" class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
> >
Name {t('instance.name')}
</th> </th>
<th <th
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase" class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
> >
URL {t('instance.url')}
</th> </th>
<th <th
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase" class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
> >
Events {t('instance.events')}
</th> </th>
<th <th
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase" class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
> >
Health Status {t('instance.healthStatus')}
</th> </th>
<th <th
class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase" class="px-6 py-3 text-left text-xs font-medium tracking-wider text-slate-400 uppercase"
> >
Response Time {t('instance.responseTime')}
</th> </th>
</tr> </tr>
</thead> </thead>
@@ -64,7 +77,7 @@
<tr class="hover:bg-slate-700/50"> <tr class="hover:bg-slate-700/50">
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
<span class="text-sm font-medium text-slate-300"> <span class="text-sm font-medium text-slate-300">
{instance.name || 'N/A'} {instance.name || t('instance.notAvailable')}
</span> </span>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
@@ -79,7 +92,7 @@
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
<span class="text-sm text-slate-300"> <span class="text-sm text-slate-300">
{instance.events !== null ? instance.events : 'N/A'} {instance.events !== null ? instance.events : t('instance.notAvailable')}
</span> </span>
</td> </td>
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
@@ -88,10 +101,10 @@
class="mr-2 inline-block h-3 w-3 rounded-full {getStatusColor( class="mr-2 inline-block h-3 w-3 rounded-full {getStatusColor(
instance.responseTime instance.responseTime
)}" )}"
title={instance.healthStatus} title={getHealthStatusText(instance.healthStatus)}
></span> ></span>
<span class="text-sm text-slate-300 capitalize"> <span class="text-sm text-slate-300 capitalize">
{instance.healthStatus} {getHealthStatusText(instance.healthStatus)}
</span> </span>
{#if instance.error} {#if instance.error}
<span class="ml-2 text-xs text-slate-500">({instance.error})</span> <span class="ml-2 text-xs text-slate-500">({instance.error})</span>
@@ -116,15 +129,16 @@
</table> </table>
<p class="py-8 text-center text-slate-400"> <p class="py-8 text-center text-slate-400">
These are the instances that are part of the github original federation list, if you want to {t('instance.description')}
add your instance to the list, please open a pull request to the <a <a
href="https://github.com/cactoide/cactoide/blob/main/federation.config.js" href="https://github.com/cactoide/cactoide/blob/main/federation.config.js"
class="text-violet-300/80">federation.config.js</a class="text-violet-300/80">{t('instance.configFile')}</a
> file. >
{t('instance.file')}
</p> </p>
{#if data.instances.length === 0} {#if data.instances.length === 0}
<div class="py-8 text-center text-slate-500">No federation instances configured.</div> <div class="py-8 text-center text-slate-500">{t('instance.noInstances')}</div>
{/if} {/if}
</div> </div>
</div> </div>