Skip to content

Add Language selector in course menu and Thai language support #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ui/src/components/LanguageSelector.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- LanguageSelector.svelte -->
<script>
import translations from '../lib/translation'; // Update the path to your translations.js file
import { locale, locales } from '../lib/i18n';

function changeLanguage(event) {
locale.set(event.target.value);
}

// Map language codes to their display names
let languageNames = Object.fromEntries(
locales.map(lang => [lang, translations[lang]?.name || lang])
);
</script>

<select
on:change={changeLanguage}
class="bg-gray-700 border border-gray-600 text-white text-sm rounded-md focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 placeholder-gray-400"
>
{#each locales as lang}
<option value={lang} class="bg-gray-700 text-white">
{languageNames[lang]}
</option>
{/each}
</select>

6 changes: 6 additions & 0 deletions ui/src/components/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { isSidebarVisible, isSearchVisible, isLoading } from "../lib/store";
import { pb, courses, resources, currentUser } from "../lib/pocketbase";
import { navigate, useLocation } from "svelte-routing";
import LanguageSelector from './LanguageSelector.svelte';
import { t } from "../lib/i18n";

export let isCoursesVisible = true;
Expand Down Expand Up @@ -56,6 +57,7 @@
/>
</button>
</div>


{#if $isLoading}
<div
Expand Down Expand Up @@ -189,5 +191,9 @@
</button>
</div>
{/if}

<LanguageSelector />
</aside>
{/if}


47 changes: 47 additions & 0 deletions ui/src/lib/translation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export default {
en: {
name: "English",
welcomeTo: "Welcome to",
pleaseLogin: "Please login to your account",
loginFailed: "Login failed. Please check your credentials and try again",
Expand Down Expand Up @@ -42,6 +43,7 @@ export default {
notStarted: "Not Started",
},
fr: {
name: "France",
welcomeTo: "Bienvenue à",
pleaseLogin: "Veuillez vous connecter à votre compte",
loginFailed:
Expand Down Expand Up @@ -85,6 +87,7 @@ export default {
notStarted: "Non commencé",
},
it: {
name: "Italian",
welcomeTo: "Benvenuto su",
pleaseLogin: "Effettua il login al tuo account",
loginFailed: "Accesso fallito. Controlla le tue credenziali e riprova",
Expand Down Expand Up @@ -127,6 +130,7 @@ export default {
notStarted: "Non iniziato",
},
ro: {
name: "Romanian",
welcomeTo: "Bine ai venit la",
pleaseLogin: "Conectează-te la contul tău",
loginFailed: "Conectare eșuată. Verifică-ți credențialele și încearcă din nou",
Expand Down Expand Up @@ -166,4 +170,47 @@ export default {
resources: "Resurse",
notStarted: "Neînceput"
},
th: {
name: "Thai",
welcomeTo: "ยินดีต้อนรับสู่",
pleaseLogin: "โปรดเข้าสู่ระบบ",
loginFailed: "Login failed. Please check your credentials and try again",
username: "Username / email",
usernameNotValid:
"Username ต้องมี 3 ตัวอักษรขึ้นไปและไม่มีช่องว่าง",
password: "รหัสผ่าน",
passwordNotValid: "รหัสผ่านต้องมี 8 ตัวอักษรขึ้นไป",
login: "เข้าสู่ระบบ",
loggingIn: "กำลังเข้าสู่ระบบ...",
alreadyLogin: "เข้าสู่ระบบแล้ว?",
myCourses: "คอร์สของฉัน",
inProgress: "อยู่ในการดำเนินการ",
nextLesson: "บทเรียนต่อไป",
summary: "สรุป",
downloads: "ดาวน์โหลด",
noCourseAssigned: "ไม่มีคอร์สที่คุณได้รับมอบหมาย",
courseAssignedCheck:
"หลักสูตรที่มอบหมายให้คุณจะแสดงที่นี่ กรุณาตรวจสอบหน้านี้เป็นระยะเพื่อให้แน่ใจว่าคุณจะไม่พลาดหลักสูตรใด ๆ",
view: "ดู",
startCourse: "เริ่มคอร์ส",
continueCourse: "เรียนต่อ",
openCourse: "เปิดคอร์ส",
resetProgress: "เริ่ม Progress ใหม่",
lessonInThisCourse: "บทเรียนในคอร์สนี้",
lessonsInThisCourse: "บทเรียนในคอร์สนี้",
completed: "เสร็จสิ้น",
inProgress: "อยู่ในการดำเนินการ",
courseAssigned: "หลักสูตรที่มอบหมายให้คุณ",
coursesAssigned: "หลักสูตรที่มอบหมายให้คุณ",
noLessonsFound: "ไม่พบบทเรียน",
findLesson: "ค้นหาบทเรียน...",
search: "ค้นหา",
COURSES: "หลักสูตร",
RESOURCES: "ทรัพยากร",
completeCourse: "ดำเนินการเรียนต่อในหลักสูตร",
courseCompleted: "หลักสูตรที่เสร็จสมบูรณ์",
previousLesson: "บทเรียนก่อนหน้า",
resources: "ทรัพยากร",
notStarted: "ยังไม่เริ่ม",
},
};