Basic translations?

This commit is contained in:
yuanhau 2025-06-07 00:04:11 +08:00
parent 7314a5fa8a
commit 61a7ecbf12
4 changed files with 17 additions and 2 deletions

View file

@ -33,8 +33,10 @@ const titleOrg = computed(() => props.title);
const titleMaxRegexDetection = /[a-zA-Z0-9]{,10}/; const titleMaxRegexDetection = /[a-zA-Z0-9]{,10}/;
const title = ref("Draggable Window"); const title = ref("Draggable Window");
onMounted(() => { onMounted(() => {
if (!titleMaxRegexPattern.test(titleOrg.value)) { if (!titleMaxRegexDetection.test(titleOrg)) {
console.log("Max Detected!!"); console.log("Max Detected!!");
} else {
title.value = titleOrg;
} }
}); });

View file

@ -138,6 +138,7 @@ const formatTime = (timestamp: any) => {
minute: "2-digit", minute: "2-digit",
}).format(timestamp); }).format(timestamp);
}; };
const scrollToBottom = () => {};
</script> </script>
<template> <template>
<blurPageBeforeLogin> <blurPageBeforeLogin>

View file

@ -1,4 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
// Translate stuff
interface translateInterfaceText {
translateText: string;
}
const translateItems: Record<string, translateInterfaceText> = {};
// Imports
import { ScanEyeIcon, RefreshCcwIcon } from "lucide-vue-next"; import { ScanEyeIcon, RefreshCcwIcon } from "lucide-vue-next";
import { import {
Tooltip, Tooltip,
@ -7,6 +14,7 @@ import {
TooltipTrigger, TooltipTrigger,
} from "@/components/ui/tooltip"; } from "@/components/ui/tooltip";
import { AhoCorasick } from "@monyone/aho-corasick"; import { AhoCorasick } from "@monyone/aho-corasick";
import translate from "translate";
async function CheckKidUnfriendlyContent(title: string, words: any[]) { async function CheckKidUnfriendlyContent(title: string, words: any[]) {
try { try {
@ -194,6 +202,7 @@ const openPublisher = (slug: string, title: string) => {
emit("openNewsSourcePage", slug, title); emit("openNewsSourcePage", slug, title);
}; };
const isLoading = computed(() => contentArray.value.length === 0); const isLoading = computed(() => contentArray.value.length === 0);
const testmessage = await translate("Hi", { from: "en", to: "es" });
</script> </script>
<template> <template>
<div class="justify-center align-center text-center"> <div class="justify-center align-center text-center">
@ -224,7 +233,7 @@ const isLoading = computed(() => contentArray.value.length === 0);
class="disabled:cursor-not-allowed" class="disabled:cursor-not-allowed"
:disabled="isPrimary(item.url, true) || switchTabs" :disabled="isPrimary(item.url, true) || switchTabs"
> >
<span>{{ item.text }}</span> <span>{{ locale === "en" ? item.text : testmessage }}</span>
</button> </button>
</template> </template>
<button v-if="canNotLoadTabUI"><RefreshCcwIcon /></button> <button v-if="canNotLoadTabUI"><RefreshCcwIcon /></button>

View file

@ -37,6 +37,9 @@ function cleanUpSlug(orgslug: string) {
} }
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
const translateQuery = getQuery(event).translate;
const translate = translateQuery === "true" ? true : false;
console.log(translate);
const slug = getRouterParam(event, "slug"); const slug = getRouterParam(event, "slug");
const cleanSlug = cleanUpSlug(slug); const cleanSlug = cleanUpSlug(slug);
if ( if (