diff --git a/src/lib/components/admin/Analytics/AnalyticsModelModal.svelte b/src/lib/components/admin/Analytics/AnalyticsModelModal.svelte
index 616a6e37b6..ca929870e4 100644
--- a/src/lib/components/admin/Analytics/AnalyticsModelModal.svelte
+++ b/src/lib/components/admin/Analytics/AnalyticsModelModal.svelte
@@ -25,7 +25,7 @@
const TIME_RANGES: { key: TimeRange; label: string; days: number }[] = [
{ key: '30d', label: '30D', days: 30 },
{ key: '1y', label: '1Y', days: 365 },
- { key: 'all', label: $i18n.t('All'), days: 0 }
+ { key: 'all', label: 'All', days: 0 }
];
let selectedRange: TimeRange = '30d';
let history: Array<{ date: string; won: number; lost: number }> = [];
@@ -239,7 +239,7 @@
: 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'}"
on:click={() => selectRange(range.key)}
>
- {range.label}
+ {range.key === 'all' ? $i18n.t('All') : range.label}
{/each}
diff --git a/src/lib/components/admin/Analytics/ChartLine.svelte b/src/lib/components/admin/Analytics/ChartLine.svelte
index 12de0eb36f..c78f6dccca 100644
--- a/src/lib/components/admin/Analytics/ChartLine.svelte
+++ b/src/lib/components/admin/Analytics/ChartLine.svelte
@@ -1,4 +1,6 @@
diff --git a/src/lib/components/chat/Settings/Notifications.svelte b/src/lib/components/chat/Settings/Notifications.svelte
index c5171b75c9..a00e42d393 100644
--- a/src/lib/components/chat/Settings/Notifications.svelte
+++ b/src/lib/components/chat/Settings/Notifications.svelte
@@ -29,13 +29,13 @@
let events: { event: string; label: string; description?: string }[] = [
{
event: 'chat.finished',
- label: $i18n.t('Chat finished'),
- description: $i18n.t('A chat run finished successfully.')
+ label: 'Chat finished',
+ description: 'A chat run finished successfully.'
},
{
event: 'chat.failed',
- label: $i18n.t('Chat failed'),
- description: $i18n.t('A chat run failed.')
+ label: 'Chat failed',
+ description: 'A chat run failed.'
}
];
let loadingTargets = false;
@@ -249,7 +249,7 @@
{#each targets as target, index}
{@const alertLabels = events
.filter((event) => target.events.includes(event.event))
- .map((event) => event.label)
+ .map((event) => $i18n.t(event.label))
.join(', ')}
@@ -388,7 +388,7 @@
type="button"
on:click={() => toggleFormEvent(event.event)}
>
- {event.label}
+ {$i18n.t(event.label)}
{/each}
diff --git a/src/lib/components/chat/Settings/Usage.svelte b/src/lib/components/chat/Settings/Usage.svelte
index 831ba565da..2a1bb97597 100644
--- a/src/lib/components/chat/Settings/Usage.svelte
+++ b/src/lib/components/chat/Settings/Usage.svelte
@@ -123,9 +123,9 @@
];
const heatmapModes: Array<{ value: HeatmapMode; label: string }> = [
- { value: 'daily', label: $i18n.t('Daily') },
- { value: 'weekly', label: $i18n.t('Weekly') },
- { value: 'cumulative', label: $i18n.t('Cumulative') }
+ { value: 'daily', label: 'Daily' },
+ { value: 'weekly', label: 'Weekly' },
+ { value: 'cumulative', label: 'Cumulative' }
];
const loadUsage = async () => {
@@ -197,7 +197,9 @@
}
labels.push({
- label: new Date(`${entry.date}T00:00:00`).toLocaleString(undefined, { month: 'short' }),
+ label: new Date(`${entry.date}T00:00:00`).toLocaleString($i18n.language, {
+ month: 'short'
+ }),
column,
span: Math.min(MIN_MONTH_LABEL_GAP, columns - column + 1)
});
diff --git a/src/lib/components/common/ChatList.svelte b/src/lib/components/common/ChatList.svelte
index 35df2e0c3e..52759f63eb 100644
--- a/src/lib/components/common/ChatList.svelte
+++ b/src/lib/components/common/ChatList.svelte
@@ -10,7 +10,7 @@
dayjs.extend(calendar);
- const i18n = getContext('i18n');
+ const i18n = getContext
('i18n');
type SortKey = 'title' | 'updated_at' | 'user_name';
export let chatList: Array<{
@@ -161,12 +161,14 @@
- {dayjs(chat.updated_at * 1000).calendar(null, {
- sameDay: '[Today] h:mm A',
- lastDay: '[Yesterday] h:mm A',
- lastWeek: 'MMM D',
- sameElse: 'MMM D, YYYY'
- })}
+ {dayjs(chat.updated_at * 1000)
+ .locale($i18n.language)
+ .calendar(null, {
+ sameDay: '[Today] h:mm A',
+ lastDay: '[Yesterday] h:mm A',
+ lastWeek: 'MMM D',
+ sameElse: 'MMM D, YYYY'
+ })}
diff --git a/src/lib/components/common/CodeEditor.svelte b/src/lib/components/common/CodeEditor.svelte
index a9078d8b21..81ee22ef2d 100644
--- a/src/lib/components/common/CodeEditor.svelte
+++ b/src/lib/components/common/CodeEditor.svelte
@@ -22,7 +22,7 @@
import { user } from '$lib/stores';
const dispatch = createEventDispatcher();
- const i18n = getContext('i18n');
+ const i18n = getContext
('i18n');
export let boilerplate = '';
export let value = '';
@@ -88,6 +88,12 @@
let isDarkMode = false;
let editorTheme = new Compartment();
let editorLanguage = new Compartment();
+ const editorPlaceholder = new Compartment();
+ $: if (codeEditor) {
+ codeEditor.dispatch({
+ effects: editorPlaceholder.reconfigure(placeholder($i18n.t('Enter your code here...')))
+ });
+ }
const getLang = async () => {
const language = languages.find((l) => l.alias.includes(lang));
@@ -210,7 +216,7 @@ print("${endTag}")
basicSetup,
keymap.of([{ key: 'Tab', run: acceptCompletion }, indentWithTab]),
indentUnit.of(' '),
- placeholder($i18n.t('Enter your code here...')),
+ editorPlaceholder.of([]),
EditorView.updateListener.of((e) => {
if (e.docChanged) {
_value = e.state.doc.toString();
diff --git a/src/lib/components/common/Collapsible.svelte b/src/lib/components/common/Collapsible.svelte
index 8bfb343697..bfbacd3175 100644
--- a/src/lib/components/common/Collapsible.svelte
+++ b/src/lib/components/common/Collapsible.svelte
@@ -3,7 +3,7 @@
import { v4 as uuidv4 } from 'uuid';
import { getContext } from 'svelte';
- const i18n = getContext('i18n');
+ const i18n = getContext('i18n');
import dayjs from '$lib/dayjs';
import duration from 'dayjs/plugin/duration';
@@ -12,23 +12,6 @@
dayjs.extend(duration);
dayjs.extend(relativeTime);
- async function loadLocale(locales) {
- if (!locales || !Array.isArray(locales)) {
- return;
- }
- for (const locale of locales) {
- try {
- dayjs.locale(locale);
- break; // Stop after successfully loading the first available locale
- } catch (error) {
- console.error(`Could not load locale '${locale}':`, error);
- }
- }
- }
-
- // Assuming $i18n.languages is an array of language codes
- $: loadLocale($i18n.languages);
-
import { slide } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
@@ -103,7 +86,10 @@
})}
{:else}
{$i18n.t('Thought for {{DURATION}}', {
- DURATION: dayjs.duration(attributes.duration, 'seconds').humanize()
+ DURATION: dayjs
+ .duration(attributes.duration, 'seconds')
+ .locale($i18n.language)
+ .humanize()
})}
{/if}
{:else if attributes?.done === 'true' || messageDone}
diff --git a/src/lib/components/common/ConfirmDialog.svelte b/src/lib/components/common/ConfirmDialog.svelte
index c1d2a5e0da..f6012dbc36 100644
--- a/src/lib/components/common/ConfirmDialog.svelte
+++ b/src/lib/components/common/ConfirmDialog.svelte
@@ -6,7 +6,7 @@
import { settings } from '$lib/stores';
import { matchKeybinding, Shortcut } from '$lib/shortcuts';
- const i18n = getContext('i18n');
+ const i18n = getContext('i18n');
const dispatch = createEventDispatcher();
import { fade } from 'svelte/transition';
@@ -18,8 +18,8 @@
export let title = '';
export let message = '';
- export let cancelLabel = $i18n.t('Cancel');
- export let confirmLabel = $i18n.t('Confirm');
+ export let cancelLabel: string | undefined = undefined;
+ export let confirmLabel: string | undefined = undefined;
export let onConfirm = () => {};
@@ -197,7 +197,7 @@
}}
type="button"
>
- {cancelLabel}
+ {cancelLabel ?? $i18n.t('Cancel')}
diff --git a/src/lib/components/common/DocxPreview.svelte b/src/lib/components/common/DocxPreview.svelte
index eb49021be8..eb95852f72 100644
--- a/src/lib/components/common/DocxPreview.svelte
+++ b/src/lib/components/common/DocxPreview.svelte
@@ -20,7 +20,7 @@
let containerEl: HTMLDivElement;
let styleEl: HTMLDivElement;
let fallbackHtml = '';
- let error = '';
+ let error = false;
let loading = false;
let renderId = 0;
let mounted = false;
@@ -36,7 +36,7 @@
if (containerEl) containerEl.innerHTML = '';
if (styleEl) styleEl.innerHTML = '';
fallbackHtml = '';
- error = '';
+ error = false;
};
const updateFitScale = () => {
@@ -157,7 +157,7 @@
fallbackHtml = DOMPurify.sanitize(await docxToHtml(arrayBuffer.slice(0)));
} catch (fallbackError) {
console.error('Error rendering DOCX fallback:', fallbackError);
- error = $i18n.t('Failed to load DOCX file. Please try downloading it instead.');
+ error = true;
}
} finally {
if (currentRender === renderId) loading = false;
@@ -200,7 +200,9 @@
{/if}
{#if error}
-
+ {$i18n.t('Failed to load DOCX file. Please try downloading it instead.')}
+
{:else if fallbackHtml}