mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
62 lines
1.6 KiB
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import { Language } from '~/lib'
|
||
2 years ago
|
import { onMounted, useGlobal, useI18n, useNuxtApp } from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
const { $e } = useNuxtApp()
|
||
2 years ago
|
|
||
2 years ago
|
const { lang: currentLang } = useGlobal()
|
||
2 years ago
|
|
||
2 years ago
|
const { availableLocales = ['en'], locale } = useI18n()
|
||
2 years ago
|
|
||
2 years ago
|
const languages = $computed(() => availableLocales.sort())
|
||
2 years ago
|
|
||
2 years ago
|
const isRtlLang = $computed(() => ['fa'].includes(currentLang.value))
|
||
2 years ago
|
|
||
2 years ago
|
function applyDirection() {
|
||
|
const targetDirection = isRtlLang ? 'rtl' : 'ltr'
|
||
|
const oppositeDirection = targetDirection === 'ltr' ? 'rtl' : 'ltr'
|
||
2 years ago
|
|
||
2 years ago
|
document.body.classList.remove(oppositeDirection)
|
||
|
document.body.classList.add(targetDirection)
|
||
|
document.body.style.direction = targetDirection
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
function changeLanguage(lang: string) {
|
||
|
currentLang.value = lang
|
||
|
locale.value = lang
|
||
2 years ago
|
|
||
2 years ago
|
applyDirection()
|
||
2 years ago
|
|
||
2 years ago
|
$e('c:navbar:lang', { lang })
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
onMounted(() => {
|
||
|
applyDirection()
|
||
|
})
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<a-menu-item
|
||
|
v-for="lang of languages"
|
||
|
:key="lang"
|
||
2 years ago
|
:class="lang === locale ? '!bg-primary bg-opacity-10 text-primary' : ''"
|
||
2 years ago
|
class="group"
|
||
|
:value="lang"
|
||
|
@click="changeLanguage(lang)"
|
||
|
>
|
||
|
<div :class="lang === locale ? '!font-semibold !text-primary' : ''" class="nc-project-menu-item capitalize">
|
||
|
{{ Language[lang] || lang }}
|
||
|
</div>
|
||
|
</a-menu-item>
|
||
|
|
||
|
<a-menu-item class="mt-1">
|
||
|
<a
|
||
|
href="https://docs.nocodb.com/engineering/translation/#how-to-contribute--for-community-members"
|
||
|
target="_blank"
|
||
|
class="caption py-2 text-primary underline hover:opacity-75"
|
||
2 years ago
|
>
|
||
2 years ago
|
{{ $t('activity.translate') }}
|
||
|
</a>
|
||
|
</a-menu-item>
|
||
2 years ago
|
</template>
|