Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
3c471ee2
Commit
3c471ee2
authored
Mar 03, 2024
by
Ased Mammad
Browse files
feat: Migrate hardcoded strings to i18n calls
parent
7a77f3c2
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
47 deletions
+62
-47
src/routes/(app)/modelfiles/edit/+page.svelte
src/routes/(app)/modelfiles/edit/+page.svelte
+14
-12
src/routes/(app)/prompts/+page.svelte
src/routes/(app)/prompts/+page.svelte
+10
-8
src/routes/(app)/prompts/create/+page.svelte
src/routes/(app)/prompts/create/+page.svelte
+9
-7
src/routes/(app)/prompts/edit/+page.svelte
src/routes/(app)/prompts/edit/+page.svelte
+9
-7
src/routes/auth/+page.svelte
src/routes/auth/+page.svelte
+7
-5
src/routes/error/+page.svelte
src/routes/error/+page.svelte
+13
-8
No files found.
src/routes/(app)/modelfiles/edit/+page.svelte
View file @
3c471ee2
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
import { onMount
, getContext
} from 'svelte';
import { page } from '$app/stores';
import { page } from '$app/stores';
import { settings, user, config, modelfiles } from '$lib/stores';
import { settings, user, config, modelfiles } from '$lib/stores';
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
const i18n = getContext('i18n');
let loading = false;
let loading = false;
let filesInputElement;
let filesInputElement;
...
@@ -248,7 +250,7 @@
...
@@ -248,7 +250,7 @@
}}
}}
/>
/>
<div class=" text-2xl font-semibold mb-6">My Modelfiles</div>
<div class=" text-2xl font-semibold mb-6">
{$i18n.t('
My Modelfiles
')}
</div>
<button
<button
class="flex space-x-1"
class="flex space-x-1"
...
@@ -270,7 +272,7 @@
...
@@ -270,7 +272,7 @@
/>
/>
</svg>
</svg>
</div>
</div>
<div class=" self-center font-medium text-sm">Back</div>
<div class=" self-center font-medium text-sm">
{$i18n.t('
Back
')}
</div>
</button>
</button>
<hr class="my-3 dark:border-gray-700" />
<hr class="my-3 dark:border-gray-700" />
...
@@ -317,7 +319,7 @@
...
@@ -317,7 +319,7 @@
<div class="my-2 flex space-x-2">
<div class="my-2 flex space-x-2">
<div class="flex-1">
<div class="flex-1">
<div class=" text-sm font-semibold mb-2">Name*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Name
')}
*</div>
<div>
<div>
<input
<input
...
@@ -330,7 +332,7 @@
...
@@ -330,7 +332,7 @@
</div>
</div>
<div class="flex-1">
<div class="flex-1">
<div class=" text-sm font-semibold mb-2">Model Tag Name*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Model Tag Name
')}
*</div>
<div>
<div>
<input
<input
...
@@ -345,7 +347,7 @@
...
@@ -345,7 +347,7 @@
</div>
</div>
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Description*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Description
')}
*</div>
<div>
<div>
<input
<input
...
@@ -359,13 +361,13 @@
...
@@ -359,13 +361,13 @@
<div class="my-2">
<div class="my-2">
<div class="flex w-full justify-between">
<div class="flex w-full justify-between">
<div class=" self-center text-sm font-semibold">Modelfile</div>
<div class=" self-center text-sm font-semibold">
{$i18n.t('
Modelfile
')}
</div>
</div>
</div>
<!-- <div class=" text-sm font-semibold mb-2"></div> -->
<!-- <div class=" text-sm font-semibold mb-2"></div> -->
<div class="mt-2">
<div class="mt-2">
<div class=" text-xs font-semibold mb-2">Content*</div>
<div class=" text-xs font-semibold mb-2">
{$i18n.t('
Content
')}
*</div>
<div>
<div>
<textarea
<textarea
...
@@ -381,7 +383,7 @@
...
@@ -381,7 +383,7 @@
<div class="my-2">
<div class="my-2">
<div class="flex w-full justify-between mb-2">
<div class="flex w-full justify-between mb-2">
<div class=" self-center text-sm font-semibold">Prompt suggestions</div>
<div class=" self-center text-sm font-semibold">
{$i18n.t('
Prompt suggestions
')}
</div>
<button
<button
class="p-1 px-3 text-xs flex rounded transition"
class="p-1 px-3 text-xs flex rounded transition"
...
@@ -438,7 +440,7 @@
...
@@ -438,7 +440,7 @@
</div>
</div>
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Categories</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Categories
')}
</div>
<div class="grid grid-cols-4">
<div class="grid grid-cols-4">
{#each Object.keys(categories) as category}
{#each Object.keys(categories) as category}
...
@@ -453,7 +455,7 @@
...
@@ -453,7 +455,7 @@
{#if pullProgress !== null}
{#if pullProgress !== null}
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Pull Progress</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Pull Progress
')}
</div>
<div class="w-full rounded-full dark:bg-gray-800">
<div class="w-full rounded-full dark:bg-gray-800">
<div
<div
class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
class="dark:bg-gray-600 text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full"
...
@@ -476,7 +478,7 @@
...
@@ -476,7 +478,7 @@
type="submit"
type="submit"
disabled={loading}
disabled={loading}
>
>
<div class=" self-center font-medium">Save & Update</div>
<div class=" self-center font-medium">
{$i18n.t('
Save & Update
')}
</div>
{#if loading}
{#if loading}
<div class="ml-1.5 self-center">
<div class="ml-1.5 self-center">
...
...
src/routes/(app)/prompts/+page.svelte
View file @
3c471ee2
...
@@ -3,17 +3,19 @@
...
@@ -3,17 +3,19 @@
import fileSaver from 'file-saver';
import fileSaver from 'file-saver';
const { saveAs } = fileSaver;
const { saveAs } = fileSaver;
import { onMount } from 'svelte';
import { onMount
, getContext
} from 'svelte';
import { WEBUI_NAME, prompts } from '$lib/stores';
import { WEBUI_NAME, prompts } from '$lib/stores';
import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts';
import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts';
import { error } from '@sveltejs/kit';
import { error } from '@sveltejs/kit';
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
const i18n = getContext('i18n');
let importFiles = '';
let importFiles = '';
let query = '';
let query = '';
const sharePrompt = async (prompt) => {
const sharePrompt = async (prompt) => {
toast.success('Redirecting you to OpenWebUI Community');
toast.success(
$i18n.t(
'Redirecting you to OpenWebUI Community')
)
;
const url = 'https://openwebui.com';
const url = 'https://openwebui.com';
...
@@ -46,7 +48,7 @@
...
@@ -46,7 +48,7 @@
<div class="flex flex-col justify-between w-full overflow-y-auto">
<div class="flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class="mb-6 flex justify-between items-center">
<div class="mb-6 flex justify-between items-center">
<div class=" text-2xl font-semibold self-center">My Prompts</div>
<div class=" text-2xl font-semibold self-center">
{$i18n.t('
My Prompts
')}
</div>
</div>
</div>
<div class=" flex w-full space-x-2">
<div class=" flex w-full space-x-2">
...
@@ -245,7 +247,7 @@
...
@@ -245,7 +247,7 @@
document.getElementById('prompts-import-input')?.click();
document.getElementById('prompts-import-input')?.click();
}}
}}
>
>
<div class=" self-center mr-2 font-medium">Import Prompts</div>
<div class=" self-center mr-2 font-medium">
{$i18n.t('
Import Prompts
')}
</div>
<div class=" self-center">
<div class=" self-center">
<svg
<svg
...
@@ -273,7 +275,7 @@
...
@@ -273,7 +275,7 @@
saveAs(blob, `prompts-export-${Date.now()}.json`);
saveAs(blob, `prompts-export-${Date.now()}.json`);
}}
}}
>
>
<div class=" self-center mr-2 font-medium">Export Prompts</div>
<div class=" self-center mr-2 font-medium">
{$i18n.t('
Export Prompts
')}
</div>
<div class=" self-center">
<div class=" self-center">
<svg
<svg
...
@@ -302,7 +304,7 @@
...
@@ -302,7 +304,7 @@
</div>
</div>
<div class=" my-16">
<div class=" my-16">
<div class=" text-2xl font-semibold mb-3">Made by OpenWebUI Community</div>
<div class=" text-2xl font-semibold mb-3">
{$i18n.t('
Made by OpenWebUI Community
')}
</div>
<a
<a
class=" flex space-x-4 cursor-pointer w-full mb-3 px-3 py-2"
class=" flex space-x-4 cursor-pointer w-full mb-3 px-3 py-2"
...
@@ -329,8 +331,8 @@
...
@@ -329,8 +331,8 @@
</div>
</div>
<div class=" self-center">
<div class=" self-center">
<div class=" font-bold">Discover a prompt</div>
<div class=" font-bold">
{$i18n.t('
Discover a prompt
')}
</div>
<div class=" text-sm">Discover, download, and explore custom prompts</div>
<div class=" text-sm">
{$i18n.t('
Discover, download, and explore custom prompts
')}
</div>
</div>
</div>
</a>
</a>
</div>
</div>
...
...
src/routes/(app)/prompts/create/+page.svelte
View file @
3c471ee2
...
@@ -3,10 +3,12 @@
...
@@ -3,10 +3,12 @@
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { prompts } from '$lib/stores';
import { prompts } from '$lib/stores';
import { onMount, tick } from 'svelte';
import { onMount, tick
, getContext
} from 'svelte';
import { createNewPrompt, getPrompts } from '$lib/apis/prompts';
import { createNewPrompt, getPrompts } from '$lib/apis/prompts';
const i18n = getContext('i18n');
let loading = false;
let loading = false;
// ///////////
// ///////////
...
@@ -92,7 +94,7 @@
...
@@ -92,7 +94,7 @@
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
<div class=" flex flex-col justify-between w-full overflow-y-auto">
<div class=" flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class=" text-2xl font-semibold mb-6">My Prompts</div>
<div class=" text-2xl font-semibold mb-6">
{$i18n.t('
My Prompts
')}
</div>
<button
<button
class="flex space-x-1"
class="flex space-x-1"
...
@@ -114,7 +116,7 @@
...
@@ -114,7 +116,7 @@
/>
/>
</svg>
</svg>
</div>
</div>
<div class=" self-center font-medium text-sm">Back</div>
<div class=" self-center font-medium text-sm">
{$i18n.t('
Back
')}
</div>
</button>
</button>
<hr class="my-3 dark:border-gray-700" />
<hr class="my-3 dark:border-gray-700" />
...
@@ -125,7 +127,7 @@
...
@@ -125,7 +127,7 @@
}}
}}
>
>
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Title*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Title
')}
*</div>
<div>
<div>
<input
<input
...
@@ -138,7 +140,7 @@
...
@@ -138,7 +140,7 @@
</div>
</div>
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Command*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Command
')}
*</div>
<div class="flex items-center mb-1">
<div class="flex items-center mb-1">
<div
<div
...
@@ -168,7 +170,7 @@
...
@@ -168,7 +170,7 @@
<div class="my-2">
<div class="my-2">
<div class="flex w-full justify-between">
<div class="flex w-full justify-between">
<div class=" self-center text-sm font-semibold">Prompt Content*</div>
<div class=" self-center text-sm font-semibold">
{$i18n.t('
Prompt Content
')}
*</div>
</div>
</div>
<div class="mt-2">
<div class="mt-2">
...
@@ -207,7 +209,7 @@
...
@@ -207,7 +209,7 @@
type="submit"
type="submit"
disabled={loading}
disabled={loading}
>
>
<div class=" self-center font-medium">Save & Create</div>
<div class=" self-center font-medium">
{$i18n.t('
Save & Create
')}
</div>
{#if loading}
{#if loading}
<div class="ml-1.5 self-center">
<div class="ml-1.5 self-center">
...
...
src/routes/(app)/prompts/edit/+page.svelte
View file @
3c471ee2
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { prompts } from '$lib/stores';
import { prompts } from '$lib/stores';
import { onMount, tick } from 'svelte';
import { onMount, tick, getContext } from 'svelte';
const i18n = getContext('i18n');
import { getPrompts, updatePromptByCommand } from '$lib/apis/prompts';
import { getPrompts, updatePromptByCommand } from '$lib/apis/prompts';
import { page } from '$app/stores';
import { page } from '$app/stores';
...
@@ -74,7 +76,7 @@
...
@@ -74,7 +76,7 @@
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
<div class="min-h-screen max-h-[100dvh] w-full flex justify-center dark:text-white">
<div class="flex flex-col justify-between w-full overflow-y-auto">
<div class="flex flex-col justify-between w-full overflow-y-auto">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class="max-w-2xl mx-auto w-full px-3 md:px-0 my-10">
<div class=" text-2xl font-semibold mb-6">My Prompts</div>
<div class=" text-2xl font-semibold mb-6">
{$i18n.t('
My Prompts
')}
</div>
<button
<button
class="flex space-x-1"
class="flex space-x-1"
...
@@ -96,7 +98,7 @@
...
@@ -96,7 +98,7 @@
/>
/>
</svg>
</svg>
</div>
</div>
<div class=" self-center font-medium text-sm">Back</div>
<div class=" self-center font-medium text-sm">
{$i18n.t('
Back
')}
</div>
</button>
</button>
<hr class="my-3 dark:border-gray-700" />
<hr class="my-3 dark:border-gray-700" />
...
@@ -107,7 +109,7 @@
...
@@ -107,7 +109,7 @@
}}
}}
>
>
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Title*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Title
')}
*</div>
<div>
<div>
<input
<input
...
@@ -120,7 +122,7 @@
...
@@ -120,7 +122,7 @@
</div>
</div>
<div class="my-2">
<div class="my-2">
<div class=" text-sm font-semibold mb-2">Command*</div>
<div class=" text-sm font-semibold mb-2">
{$i18n.t('
Command
')}
*</div>
<div class="flex items-center mb-1">
<div class="flex items-center mb-1">
<div
<div
...
@@ -151,7 +153,7 @@
...
@@ -151,7 +153,7 @@
<div class="my-2">
<div class="my-2">
<div class="flex w-full justify-between">
<div class="flex w-full justify-between">
<div class=" self-center text-sm font-semibold">Prompt Content*</div>
<div class=" self-center text-sm font-semibold">
{$i18n.t('
Prompt Content
')}
*</div>
</div>
</div>
<div class="mt-2">
<div class="mt-2">
...
@@ -184,7 +186,7 @@
...
@@ -184,7 +186,7 @@
type="submit"
type="submit"
disabled={loading}
disabled={loading}
>
>
<div class=" self-center font-medium">Save & Update</div>
<div class=" self-center font-medium">
{$i18n.t('
Save & Update
')}
</div>
{#if loading}
{#if loading}
<div class="ml-1.5 self-center">
<div class="ml-1.5 self-center">
...
...
src/routes/auth/+page.svelte
View file @
3c471ee2
...
@@ -3,9 +3,11 @@
...
@@ -3,9 +3,11 @@
import { userSignIn, userSignUp } from '$lib/apis/auths';
import { userSignIn, userSignUp } from '$lib/apis/auths';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { WEBUI_NAME, config, user } from '$lib/stores';
import { WEBUI_NAME, config, user } from '$lib/stores';
import { onMount } from 'svelte';
import { onMount
, getContext
} from 'svelte';
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
const i18n = getContext('i18n');
let loaded = false;
let loaded = false;
let mode = 'signin';
let mode = 'signin';
...
@@ -16,7 +18,7 @@
...
@@ -16,7 +18,7 @@
const setSessionUser = async (sessionUser) => {
const setSessionUser = async (sessionUser) => {
if (sessionUser) {
if (sessionUser) {
console.log(sessionUser);
console.log(sessionUser);
toast.success(`You're now logged in.`);
toast.success(
$i18n.t(
`You're now logged in.`)
)
;
localStorage.token = sessionUser.token;
localStorage.token = sessionUser.token;
await user.set(sessionUser);
await user.set(sessionUser);
goto('/');
goto('/');
...
@@ -109,7 +111,7 @@
...
@@ -109,7 +111,7 @@
<div class="flex flex-col mt-4">
<div class="flex flex-col mt-4">
{#if mode === 'signup'}
{#if mode === 'signup'}
<div>
<div>
<div class=" text-sm font-semibold text-left mb-1">Name</div>
<div class=" text-sm font-semibold text-left mb-1">
{$i18n.t('
Name
')}
</div>
<input
<input
bind:value={name}
bind:value={name}
type="text"
type="text"
...
@@ -124,7 +126,7 @@
...
@@ -124,7 +126,7 @@
{/if}
{/if}
<div class="mb-2">
<div class="mb-2">
<div class=" text-sm font-semibold text-left mb-1">Email</div>
<div class=" text-sm font-semibold text-left mb-1">
{$i18n.t('
Email
')}
</div>
<input
<input
bind:value={email}
bind:value={email}
type="email"
type="email"
...
@@ -136,7 +138,7 @@
...
@@ -136,7 +138,7 @@
</div>
</div>
<div>
<div>
<div class=" text-sm font-semibold text-left mb-1">Password</div>
<div class=" text-sm font-semibold text-left mb-1">
{$i18n.t('
Password
')}
</div>
<input
<input
bind:value={password}
bind:value={password}
type="password"
type="password"
...
...
src/routes/error/+page.svelte
View file @
3c471ee2
<script>
<script>
import { goto } from '$app/navigation';
import { goto } from '$app/navigation';
import { WEBUI_NAME, config } from '$lib/stores';
import { WEBUI_NAME, config } from '$lib/stores';
import { onMount } from 'svelte';
import { onMount, getContext } from 'svelte';
const i18n = getContext('i18n');
let loaded = false;
let loaded = false;
...
@@ -19,22 +21,25 @@
...
@@ -19,22 +21,25 @@
<div class="absolute rounded-xl w-full h-full backdrop-blur flex justify-center">
<div class="absolute rounded-xl w-full h-full backdrop-blur flex justify-center">
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="max-w-md">
<div class="max-w-md">
<div class="text-center text-2xl font-medium z-50">{$WEBUI_NAME} Backend Required</div>
<div class="text-center text-2xl font-medium z-50">
{$i18n.t('{{webui_name}} Backend Required', { webui_name: $WEBUI_NAME })}
</div>
<div class=" mt-4 text-center text-sm w-full">
<div class=" mt-4 text-center text-sm w-full">
Oops! You're using an unsupported method (frontend only). Please serve the WebUI from
{$i18n.t(
the backend.
"Oops! You're using an unsupported method (frontend only). Please serve the WebUI from the backend."
)}
<br class=" " />
<br class=" " />
<br class=" " />
<br class=" " />
<a
<a
class=" font-semibold underline"
class=" font-semibold underline"
href="https://github.com/open-webui/open-webui#how-to-install-"
href="https://github.com/open-webui/open-webui#how-to-install-"
target="_blank">See readme.md for instructions</a
target="_blank">
{$i18n.t('
See readme.md for instructions
')}
</a
>
>
or
{$i18n.t('or')}
<a class=" font-semibold underline" href="https://discord.gg/5rJgQTnV4s" target="_blank"
<a class=" font-semibold underline" href="https://discord.gg/5rJgQTnV4s" target="_blank"
>join our Discord for help.</a
>
{$i18n.t('
join our Discord for help.
')}
</a
>
>
</div>
</div>
...
@@ -45,7 +50,7 @@
...
@@ -45,7 +50,7 @@
location.href = '/';
location.href = '/';
}}
}}
>
>
Check Again
{$i18n.t('
Check Again
')}
</button>
</button>
</div>
</div>
</div>
</div>
...
...
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment