Merge pull request #1 from pascalyazid/fix/fix-default-target-lang
Fix/fix default target lang
This commit is contained in:
13 files changed
+158
-9763
No files matched your search
@@ -5,6 +5,7 @@
|
||||
.nitro
|
||||
.cache
|
||||
dist
|
||||
package-lock.json
|
||||
|
||||
# Node dependencies
|
||||
node_modules
|
||||
@@ -22,3 +23,6 @@ logs
|
||||
.env
|
||||
.env.*
|
||||
!.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 {
|
||||
label?: string;
|
||||
modelValue: string;
|
||||
modelValue?: string;
|
||||
direction?: string;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
(e: "update:modelValue", value: string): void;
|
||||
}>();
|
||||
|
||||
|
||||
const model = defineModel<string>({ default: 'en' });
|
||||
|
||||
const { languages } = useLanguages();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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 }}
|
||||
</label>
|
||||
<select
|
||||
class="language-selector-input select"
|
||||
:value="props.modelValue"
|
||||
@change="
|
||||
emit('update:modelValue', ($event.target as HTMLSelectElement).value)
|
||||
"
|
||||
v-model="model"
|
||||
:id="props.direction"
|
||||
>
|
||||
<option v-for="lang in languages" :key="lang.code" :value="lang.code">
|
||||
{{ lang.name }}
|
||||
|
||||
@@ -12,19 +12,14 @@ const emit = defineEmits<{
|
||||
|
||||
const MODEL_OPTIONS = [
|
||||
{
|
||||
value: "translategemma:1b",
|
||||
label: "TranslateGemma 1B",
|
||||
description: "Faster, lower quality (~2GB VRAM)",
|
||||
},
|
||||
{
|
||||
value: "translategemma:2b",
|
||||
label: "TranslateGemma 2B",
|
||||
description: "Balanced speed/quality (~3GB VRAM)",
|
||||
value: "translategemma:12b",
|
||||
label: "TranslateGemma 12B",
|
||||
description: " (Best Quality ~12GB VRAM)",
|
||||
},
|
||||
{
|
||||
value: "translategemma:4b",
|
||||
label: "TranslateGemma 4B",
|
||||
description: "Best quality (~4GB VRAM)",
|
||||
description: "(Balanced speed/quality ~4GB VRAM)",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -65,11 +65,12 @@ watch(
|
||||
|
||||
<template>
|
||||
<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 }}
|
||||
</label>
|
||||
<textarea
|
||||
ref="textareaRef"
|
||||
id="textinput"
|
||||
class="text-input-area textarea"
|
||||
:value="props.modelValue"
|
||||
:placeholder="props.placeholder"
|
||||
|
||||
@@ -3,9 +3,9 @@ import { useToast } from "~/composables/useToast";
|
||||
|
||||
interface Props {
|
||||
label?: string;
|
||||
text: string;
|
||||
text: string | null;
|
||||
loading?: boolean;
|
||||
error?: string;
|
||||
error?: string | null;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
@@ -29,8 +29,12 @@ function detectBrowserLanguage(): string {
|
||||
}
|
||||
|
||||
const detectedLang = detectBrowserLanguage();
|
||||
|
||||
const defaultSource = detectedLang;
|
||||
const defaultTarget = detectedLang === "en" ? "es" : "en";
|
||||
var defaultTarget = "en"
|
||||
if(detectedLang == "en") {
|
||||
defaultTarget = "es";
|
||||
}
|
||||
|
||||
export function useTranslation(options: UseTranslationOptions = {}) {
|
||||
const sourceText = ref("");
|
||||
@@ -96,6 +100,7 @@ export function useTranslation(options: UseTranslationOptions = {}) {
|
||||
options: {
|
||||
onChunk?: (chunk: string) => void;
|
||||
onComplete?: (fullText: string) => void;
|
||||
model?: Ref<string>;
|
||||
} = {},
|
||||
) {
|
||||
if (!isReadyToTranslate.value) {
|
||||
|
||||
+12
-1
@@ -44,7 +44,11 @@ function handleModelUpdate(newModel: string) {
|
||||
</main>
|
||||
<footer class="app-footer">
|
||||
<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>
|
||||
</footer>
|
||||
|
||||
@@ -59,6 +63,13 @@ function handleModelUpdate(newModel: string) {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.nav-link {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
.nav-link:hover {
|
||||
color: var(--primary-color);
|
||||
}
|
||||
.app-layout {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
|
||||
+2
-3
@@ -18,7 +18,6 @@ const {
|
||||
swapLanguages,
|
||||
clearInput,
|
||||
} = useTranslation({ model });
|
||||
|
||||
const { status, isReady, errorMessage, checkStatus } = useOllamaStatus();
|
||||
|
||||
function handleTranslate() {
|
||||
@@ -60,7 +59,7 @@ function handleKeydown(event: KeyboardEvent) {
|
||||
|
||||
<div class="translation-controls">
|
||||
<div class="language-selectors">
|
||||
<LanguageSelector label="Translate from" v-model="sourceLang" />
|
||||
<LanguageSelector label="Translate from" v-model="sourceLang" direction="lang.source" />
|
||||
<button
|
||||
class="swap-button btn"
|
||||
@click="swapLanguages"
|
||||
@@ -70,7 +69,7 @@ function handleKeydown(event: KeyboardEvent) {
|
||||
>
|
||||
⇆
|
||||
</button>
|
||||
<LanguageSelector label="Translate to" v-model="targetLang" />
|
||||
<LanguageSelector label="Translate to" v-model="targetLang" direction="lang.target" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Generated
-9732
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -12,7 +12,7 @@
|
||||
"dependencies": {
|
||||
"nuxt": "^4.3.1",
|
||||
"vue": "^3.5.30",
|
||||
"vue-router": "^4.6.4"
|
||||
"vue-router": "^5.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
|
||||
@@ -32,8 +32,7 @@ export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig();
|
||||
const ollamaUrl = config.ollamahost;
|
||||
const ALLOWED_MODELS = [
|
||||
"translategemma:1b",
|
||||
"translategemma:2b",
|
||||
"translategemma:12b",
|
||||
"translategemma:4b",
|
||||
];
|
||||
const model =
|
||||
|
||||
@@ -58,8 +58,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const ollamaUrl = config.ollamahost;
|
||||
const ALLOWED_MODELS = [
|
||||
"translategemma:1b",
|
||||
"translategemma:2b",
|
||||
"translategemma:12b",
|
||||
"translategemma:4b",
|
||||
];
|
||||
const model =
|
||||
|
||||
Reference in new issue
Block a user