Merge pull request #1 from pascalyazid/fix/fix-default-target-lang
Fix/fix default target lang
This commit is contained in:
13 files changed
+159
-9764
No files matched your search
@@ -5,6 +5,7 @@
|
|||||||
.nitro
|
.nitro
|
||||||
.cache
|
.cache
|
||||||
dist
|
dist
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
# Node dependencies
|
# Node dependencies
|
||||||
node_modules
|
node_modules
|
||||||
@@ -22,3 +23,6 @@ logs
|
|||||||
.env
|
.env
|
||||||
.env.*
|
.env.*
|
||||||
!.env.example
|
!.env.example
|
||||||
|
|
||||||
|
#IDE
|
||||||
|
.vscode
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
# Quick Ling Setup
|
||||||
|
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Make sure to install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Ollama Setup (Optional)
|
||||||
|
|
||||||
|
To use the translation service, you need to have Ollama installed and the translategemma model loaded.
|
||||||
|
|
||||||
|
### Installing Ollama
|
||||||
|
|
||||||
|
#### Linux and macOS
|
||||||
|
```bash
|
||||||
|
# Add Ollama repository
|
||||||
|
curl -fsSL https://ollama.com/install.sh | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Windows (PowerShell)
|
||||||
|
```powershell
|
||||||
|
# Download and install
|
||||||
|
irm https://ollama.com/install.ps1 | iex
|
||||||
|
```
|
||||||
|
|
||||||
|
### Pulling the TranslateGemma Model
|
||||||
|
|
||||||
|
After installing Ollama, pull the translategemma model:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Pull the translation model
|
||||||
|
ollama pull translategemma:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
For specific model versions:
|
||||||
|
```bash
|
||||||
|
# Pull a specific version
|
||||||
|
ollama pull translategemma:12b
|
||||||
|
```
|
||||||
|
|
||||||
|
### Running Ollama Server
|
||||||
|
|
||||||
|
Start the Ollama server (runs on `localhost:11434` by default):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ollama serve
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Server
|
||||||
|
|
||||||
|
Start the development server on `http://localhost:3000`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm dev
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn dev
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
Build the application for production:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm build
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Locally preview production build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# npm
|
||||||
|
npm run preview
|
||||||
|
|
||||||
|
# pnpm
|
||||||
|
pnpm preview
|
||||||
|
|
||||||
|
# yarn
|
||||||
|
yarn preview
|
||||||
|
|
||||||
|
# bun
|
||||||
|
bun run preview
|
||||||
|
```
|
||||||
|
|
||||||
|
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
||||||
@@ -3,28 +3,27 @@ import { useLanguages } from "~/composables/useLanguages";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label?: string;
|
label?: string;
|
||||||
modelValue: string;
|
modelValue?: string;
|
||||||
|
direction?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: "update:modelValue", value: string): void;
|
|
||||||
}>();
|
const model = defineModel<string>({ default: 'en' });
|
||||||
|
|
||||||
const { languages } = useLanguages();
|
const { languages } = useLanguages();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="language-selector">
|
<div class="language-selector">
|
||||||
<label v-if="props.label" class="language-selector-label">
|
<label v-if="props.label" class="language-selector-label" :for="props.direction">
|
||||||
{{ props.label }}
|
{{ props.label }}
|
||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
class="language-selector-input select"
|
class="language-selector-input select"
|
||||||
:value="props.modelValue"
|
v-model="model"
|
||||||
@change="
|
:id="props.direction"
|
||||||
emit('update:modelValue', ($event.target as HTMLSelectElement).value)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<option v-for="lang in languages" :key="lang.code" :value="lang.code">
|
<option v-for="lang in languages" :key="lang.code" :value="lang.code">
|
||||||
{{ lang.name }}
|
{{ lang.name }}
|
||||||
|
|||||||
@@ -12,19 +12,14 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
const MODEL_OPTIONS = [
|
const MODEL_OPTIONS = [
|
||||||
{
|
{
|
||||||
value: "translategemma:1b",
|
value: "translategemma:12b",
|
||||||
label: "TranslateGemma 1B",
|
label: "TranslateGemma 12B",
|
||||||
description: "Faster, lower quality (~2GB VRAM)",
|
description: " (Best Quality ~12GB VRAM)",
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "translategemma:2b",
|
|
||||||
label: "TranslateGemma 2B",
|
|
||||||
description: "Balanced speed/quality (~3GB VRAM)",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "translategemma:4b",
|
value: "translategemma:4b",
|
||||||
label: "TranslateGemma 4B",
|
label: "TranslateGemma 4B",
|
||||||
description: "Best quality (~4GB VRAM)",
|
description: "(Balanced speed/quality ~4GB VRAM)",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -65,11 +65,12 @@ watch(
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="text-input">
|
<div class="text-input">
|
||||||
<label v-if="props.label" class="text-input-label">
|
<label v-if="props.label" class="text-input-label" for="textinput">
|
||||||
{{ props.label }}
|
{{ props.label }}
|
||||||
</label>
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
ref="textareaRef"
|
ref="textareaRef"
|
||||||
|
id="textinput"
|
||||||
class="text-input-area textarea"
|
class="text-input-area textarea"
|
||||||
:value="props.modelValue"
|
:value="props.modelValue"
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { useToast } from "~/composables/useToast";
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label?: string;
|
label?: string;
|
||||||
text: string;
|
text: string | null;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
error?: string;
|
error?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|||||||
@@ -29,8 +29,12 @@ function detectBrowserLanguage(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const detectedLang = detectBrowserLanguage();
|
const detectedLang = detectBrowserLanguage();
|
||||||
|
|
||||||
const defaultSource = detectedLang;
|
const defaultSource = detectedLang;
|
||||||
const defaultTarget = detectedLang === "en" ? "es" : "en";
|
var defaultTarget = "en"
|
||||||
|
if(detectedLang == "en") {
|
||||||
|
defaultTarget = "es";
|
||||||
|
}
|
||||||
|
|
||||||
export function useTranslation(options: UseTranslationOptions = {}) {
|
export function useTranslation(options: UseTranslationOptions = {}) {
|
||||||
const sourceText = ref("");
|
const sourceText = ref("");
|
||||||
@@ -96,6 +100,7 @@ export function useTranslation(options: UseTranslationOptions = {}) {
|
|||||||
options: {
|
options: {
|
||||||
onChunk?: (chunk: string) => void;
|
onChunk?: (chunk: string) => void;
|
||||||
onComplete?: (fullText: string) => void;
|
onComplete?: (fullText: string) => void;
|
||||||
|
model?: Ref<string>;
|
||||||
} = {},
|
} = {},
|
||||||
) {
|
) {
|
||||||
if (!isReadyToTranslate.value) {
|
if (!isReadyToTranslate.value) {
|
||||||
|
|||||||
+13
-2
@@ -44,7 +44,11 @@ function handleModelUpdate(newModel: string) {
|
|||||||
</main>
|
</main>
|
||||||
<footer class="app-footer">
|
<footer class="app-footer">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<p>Powered by translategemma • Ollama</p>
|
<p>Powered by
|
||||||
|
<NuxtLink to ="https://ollama.com/library/translategemma" class="nav-link">translategemma</NuxtLink>
|
||||||
|
•
|
||||||
|
<NuxtLink to ="https://ollama.com" class="nav-link">ollama</NuxtLink></p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@@ -59,6 +63,13 @@ function handleModelUpdate(newModel: string) {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.nav-link {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.nav-link:hover {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
.app-layout {
|
.app-layout {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -144,4 +155,4 @@ function handleModelUpdate(newModel: string) {
|
|||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
+2
-3
@@ -18,7 +18,6 @@ const {
|
|||||||
swapLanguages,
|
swapLanguages,
|
||||||
clearInput,
|
clearInput,
|
||||||
} = useTranslation({ model });
|
} = useTranslation({ model });
|
||||||
|
|
||||||
const { status, isReady, errorMessage, checkStatus } = useOllamaStatus();
|
const { status, isReady, errorMessage, checkStatus } = useOllamaStatus();
|
||||||
|
|
||||||
function handleTranslate() {
|
function handleTranslate() {
|
||||||
@@ -60,7 +59,7 @@ function handleKeydown(event: KeyboardEvent) {
|
|||||||
|
|
||||||
<div class="translation-controls">
|
<div class="translation-controls">
|
||||||
<div class="language-selectors">
|
<div class="language-selectors">
|
||||||
<LanguageSelector label="Translate from" v-model="sourceLang" />
|
<LanguageSelector label="Translate from" v-model="sourceLang" direction="lang.source" />
|
||||||
<button
|
<button
|
||||||
class="swap-button btn"
|
class="swap-button btn"
|
||||||
@click="swapLanguages"
|
@click="swapLanguages"
|
||||||
@@ -70,7 +69,7 @@ function handleKeydown(event: KeyboardEvent) {
|
|||||||
>
|
>
|
||||||
⇆
|
⇆
|
||||||
</button>
|
</button>
|
||||||
<LanguageSelector label="Translate to" v-model="targetLang" />
|
<LanguageSelector label="Translate to" v-model="targetLang" direction="lang.target" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Generated
-9732
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nuxt": "^4.3.1",
|
"nuxt": "^4.3.1",
|
||||||
"vue": "^3.5.30",
|
"vue": "^3.5.30",
|
||||||
"vue-router": "^4.6.4"
|
"vue-router": "^5.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.9.3"
|
"typescript": "^5.9.3"
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig();
|
||||||
const ollamaUrl = config.ollamahost;
|
const ollamaUrl = config.ollamahost;
|
||||||
const ALLOWED_MODELS = [
|
const ALLOWED_MODELS = [
|
||||||
"translategemma:1b",
|
"translategemma:12b",
|
||||||
"translategemma:2b",
|
|
||||||
"translategemma:4b",
|
"translategemma:4b",
|
||||||
];
|
];
|
||||||
const model =
|
const model =
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const ollamaUrl = config.ollamahost;
|
const ollamaUrl = config.ollamahost;
|
||||||
const ALLOWED_MODELS = [
|
const ALLOWED_MODELS = [
|
||||||
"translategemma:1b",
|
"translategemma:12b",
|
||||||
"translategemma:2b",
|
|
||||||
"translategemma:4b",
|
"translategemma:4b",
|
||||||
];
|
];
|
||||||
const model =
|
const model =
|
||||||
|
|||||||
Reference in new issue
Block a user