fix: translations
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
<template #prefix>
|
<template #prefix>
|
||||||
<Plus class="h-4 w-4" />
|
<Plus class="h-4 w-4" />
|
||||||
</template>
|
</template>
|
||||||
New Course
|
{{ __("New Course") }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
:class="{ 'text-gray-900': selected }"
|
:class="{ 'text-gray-900': selected }"
|
||||||
>
|
>
|
||||||
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
|
<component v-if="tab.icon" :is="tab.icon" class="h-5" />
|
||||||
{{ tab.label }}
|
{{ __(tab.label) }}
|
||||||
<Badge
|
<Badge
|
||||||
:class="{ 'text-gray-900 border border-gray-900': selected }"
|
:class="{ 'text-gray-900 border border-gray-900': selected }"
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
@@ -42,14 +42,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #default="{ tab }">
|
<template #default="{ tab }">
|
||||||
<div class="grid grid-cols-3 gap-8 mt-5" v-if="tab.courses && tab.courses.value.length">
|
<div v-if="tab.courses && tab.courses.value.length" class="grid grid-cols-3 gap-8 mt-5" >
|
||||||
<router-link v-for="course in tab.courses.value" :to="{ name: 'CourseDetail', params: { course: course.name } }">
|
<router-link v-for="course in tab.courses.value" :to="{ name: 'CourseDetail', params: { course: course.name } }">
|
||||||
<CourseCard :course="course" />
|
<CourseCard :course="course" />
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="grid flex-1 place-items-center text-xl font-medium text-gray-500">
|
<div v-else class="grid flex-1 place-items-center text-xl font-medium text-gray-500">
|
||||||
<div class="flex flex-col items-center justify-center mt-4">
|
<div class="flex flex-col items-center justify-center mt-4">
|
||||||
<div>No {{ tab.label.toLowerCase() }} courses found</div>
|
<div>
|
||||||
|
{{ __("No {0} courses found").format(tab.label.toLowerCase()) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -136,7 +138,6 @@ const orderBy = 'enrollment';
|
|||||||
function sort_courses(order) {
|
function sort_courses(order) {
|
||||||
const categories = ['live', 'upcoming', 'enrolled', 'created', 'under_review'];
|
const categories = ['live', 'upcoming', 'enrolled', 'created', 'under_review'];
|
||||||
categories.forEach(category => {
|
categories.forEach(category => {
|
||||||
console.log(courses.data)
|
|
||||||
courses.data[category] = courses.data[category].sort((a, b) => {
|
courses.data[category] = courses.data[category].sort((a, b) => {
|
||||||
if (order === 'enrollment') {
|
if (order === 'enrollment') {
|
||||||
return b.enrollment_count - a.enrollment_count;
|
return b.enrollment_count - a.enrollment_count;
|
||||||
|
|||||||
@@ -2,21 +2,15 @@ import { createResource } from 'frappe-ui'
|
|||||||
|
|
||||||
export default function translationPlugin(app) {
|
export default function translationPlugin(app) {
|
||||||
app.config.globalProperties.__ = translate
|
app.config.globalProperties.__ = translate
|
||||||
console.log(window.translatedMessages)
|
|
||||||
if (!window.translatedMessages) fetchTranslations()
|
if (!window.translatedMessages) fetchTranslations()
|
||||||
}
|
}
|
||||||
|
|
||||||
function translate(message) {
|
function translate(message) {
|
||||||
let lang = window.lang || 'hi'
|
let translatedMessages = window.translatedMessages || {}
|
||||||
let translatedMessages = window.translatedMessages || {
|
|
||||||
'All Courses': 'सभी पाठ्यक्रम',
|
|
||||||
Live: 'लाइव',
|
|
||||||
}
|
|
||||||
let translatedMessage = translatedMessages[message] || message
|
let translatedMessage = translatedMessages[message] || message
|
||||||
|
|
||||||
const hasPlaceholders = /{\d+}/.test(message)
|
const hasPlaceholders = /{\d+}/.test(message)
|
||||||
console.log(hasPlaceholders)
|
|
||||||
if (!hasPlaceholders) {
|
if (!hasPlaceholders) {
|
||||||
console.log(translatedMessage)
|
|
||||||
return translatedMessage
|
return translatedMessage
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -34,14 +28,12 @@ function translate(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetchTranslations(lang) {
|
function fetchTranslations(lang) {
|
||||||
console.log('called')
|
|
||||||
createResource({
|
createResource({
|
||||||
url: 'lms.lms.api.get_translations',
|
url: 'lms.lms.api.get_translations',
|
||||||
cache: 'translations',
|
cache: 'translations',
|
||||||
auto: true,
|
auto: true,
|
||||||
transform: (data) => {
|
transform: (data) => {
|
||||||
console.log(data)
|
window.translatedMessages = data
|
||||||
window.translatedMessages = data.message
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user