Skip to content

Commit

Permalink
Work around vue-i18n #1403
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Aug 7, 2023
1 parent 39e7aae commit 3f66d31
Show file tree
Hide file tree
Showing 37 changed files with 229 additions and 251 deletions.
4 changes: 1 addition & 3 deletions Tekst-Web/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import { useInitializeApp } from '@/init';
import LoginModal from '@/components/LoginModal.vue';
import HugeLabeledIcon from '@/components/HugeLabeledIcon.vue';
import ErrorTwotone from '@vicons/material/ErrorTwotone';
import { useI18n } from 'vue-i18n';
const state = useStateStore();
const themeVars = useThemeVars();
const { initialized, error } = useInitializeApp();
const { theme, themeOverrides, mainBgColor, contentBgColor, accentColors } = useTheme();
const { t } = useI18n({ useScope: 'global' });
// i18n
const nUiLangLocale = computed(() => localeProfiles[state.locale].nUiLangLocale);
Expand All @@ -37,7 +35,7 @@ const nUiDateLocale = computed(() => localeProfiles[state.locale].nUiDateLocale)
<div id="app-container">
<huge-labeled-icon
v-if="initialized && error"
:message="t('init.error')"
:message="$t('init.error')"
:loading="!error && !initialized"
:icon="ErrorTwotone"
/>
Expand Down
16 changes: 8 additions & 8 deletions Tekst-Web/src/components/LoginModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ onMounted(() => {
embedded
>
<div class="form-container">
<h2 style="text-align: center">{{ t('account.login.heading') }}</h2>
<h2 style="text-align: center">{{ $t('account.login.heading') }}</h2>
<div v-show="args[0]" class="login-message">{{ args[0] }}</div>
<n-form
ref="formRef"
Expand All @@ -102,12 +102,12 @@ onMounted(() => {
<n-form-item
path="email"
:rule="accountFormRules.loginEmail"
:label="t('models.user.email')"
:label="$t('models.user.email')"
>
<n-input
v-model:value="formModel.email"
type="text"
:placeholder="t('models.user.email')"
:placeholder="$t('models.user.email')"
@keydown.enter.prevent
:disabled="isResolving"
ref="emailInputRef"
Expand All @@ -116,12 +116,12 @@ onMounted(() => {
<n-form-item
path="password"
:rule="accountFormRules.loginPassword"
:label="t('models.user.password')"
:label="$t('models.user.password')"
>
<n-input
v-model:value="formModel.password"
type="password"
:placeholder="t('models.user.password')"
:placeholder="$t('models.user.password')"
:disabled="isResolving"
@keyup.enter="handleLoginClick(resolve, args[1])"
/>
Expand All @@ -135,7 +135,7 @@ onMounted(() => {
style="margin-bottom: 2rem; font-size: var(--app-ui-font-size-mini)"
@click="handleForgotPasswordClick(resolve)"
>
{{ t('account.forgotPassword.forgotPassword') }}
{{ $t('account.forgotPassword.forgotPassword') }}
</n-button>
</div>

Expand All @@ -147,10 +147,10 @@ onMounted(() => {
:loading="isResolving"
:disabled="isResolving"
>
{{ t('account.loginBtn') }}
{{ $t('account.loginBtn') }}
</n-button>
<n-button v-if="args[2]" secondary block @click="reject(switchToRegistration())">
{{ t('account.switchToRegister') }}
{{ $t('account.switchToRegister') }}
</n-button>
</n-space>
</div>
Expand Down
5 changes: 1 addition & 4 deletions Tekst-Web/src/components/admin/InsertLevelButton.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<script setup lang="ts">
import { NButton, NIcon } from 'naive-ui';
import AddRound from '@vicons/material/AddRound';
import { useI18n } from 'vue-i18n';
defineProps<{
level: number;
}>();
defineEmits(['click']);
const { t } = useI18n({ useScope: 'global' });
</script>

<template>
Expand All @@ -17,7 +14,7 @@ const { t } = useI18n({ useScope: 'global' });
<n-button
secondary
circle
:title="t('admin.texts.levels.tipInsertLevel', { n: level + 1 })"
:title="$t('admin.texts.levels.tipInsertLevel', { n: level + 1 })"
@click="$emit('click', level)"
:focusable="false"
>
Expand Down
28 changes: 13 additions & 15 deletions Tekst-Web/src/components/admin/UserListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import CheckCircleRound from '@vicons/material/CheckCircleRound';
import QuestionMarkRound from '@vicons/material/QuestionMarkRound';
import ClearRound from '@vicons/material/ClearRound';
import { usePlatformData } from '@/platformData';
import { useI18n } from 'vue-i18n';
defineProps<{
targetUser: UserRead;
Expand All @@ -20,7 +19,6 @@ defineProps<{
defineEmits(['superuserClick', 'activeClick', 'verifiedClick', 'deleteClick']);
const { pfData } = usePlatformData();
const { t } = useI18n({ useScope: 'global' });
const statusBtnMinWidth = '128px';
</script>
Expand All @@ -34,14 +32,14 @@ const statusBtnMinWidth = '128px';
>
<template #description>
<a
:href="`mailto:${targetUser.email}?subject=${t('admin.users.mailtoSubject', {
:href="`mailto:${targetUser.email}?subject=${$t('admin.users.mailtoSubject', {
platform: pfData?.info?.platformName,
})}`"
:title="t('admin.users.mailtoLinkTitle', { username: targetUser.username })"
:title="$t('admin.users.mailtoLinkTitle', { username: targetUser.username })"
>
{{ targetUser.email }}
</a>
– {{ t('admin.users.registeredAt') }}
– {{ $t('admin.users.registeredAt') }}
<n-time :time="new Date(targetUser.createdAt)" type="date" />
</template>
<template #header-extra>
Expand All @@ -53,15 +51,15 @@ const statusBtnMinWidth = '128px';
:type="targetUser.isSuperuser ? 'info' : 'default'"
:title="
targetUser.isSuperuser
? t('admin.users.statusBtnTitle.setUser', { username: targetUser.username })
: t('admin.users.statusBtnTitle.setSuperuser', { username: targetUser.username })
? $t('admin.users.statusBtnTitle.setUser', { username: targetUser.username })
: $t('admin.users.statusBtnTitle.setSuperuser', { username: targetUser.username })
"
size="tiny"
:style="{ minWidth: statusBtnMinWidth }"
@click="$emit('superuserClick', targetUser)"
>
{{
targetUser.isSuperuser ? t('models.user.isSuperuser') : t('models.user.modelLabel')
targetUser.isSuperuser ? $t('models.user.isSuperuser') : $t('models.user.modelLabel')
}}
<template #icon>
<n-icon :component="targetUser.isSuperuser ? StarRound : PersonRound" />
Expand All @@ -74,14 +72,14 @@ const statusBtnMinWidth = '128px';
:type="targetUser.isActive ? 'success' : 'error'"
:title="
targetUser.isActive
? t('admin.users.statusBtnTitle.setInactive', { username: targetUser.username })
: t('admin.users.statusBtnTitle.setActive', { username: targetUser.username })
? $t('admin.users.statusBtnTitle.setInactive', { username: targetUser.username })
: $t('admin.users.statusBtnTitle.setActive', { username: targetUser.username })
"
size="tiny"
:style="{ minWidth: statusBtnMinWidth }"
@click="$emit('activeClick', targetUser)"
>
{{ targetUser.isActive ? t('models.user.isActive') : t('models.user.isInactive') }}
{{ targetUser.isActive ? $t('models.user.isActive') : $t('models.user.isInactive') }}
<template #icon>
<n-icon :component="targetUser.isActive ? CheckCircleRound : BlockRound" />
</template>
Expand All @@ -93,15 +91,15 @@ const statusBtnMinWidth = '128px';
:type="targetUser.isVerified ? 'success' : 'warning'"
:title="
targetUser.isVerified
? t('admin.users.statusBtnTitle.setUnverified', { username: targetUser.username })
: t('admin.users.statusBtnTitle.setVerified', { username: targetUser.username })
? $t('admin.users.statusBtnTitle.setUnverified', { username: targetUser.username })
: $t('admin.users.statusBtnTitle.setVerified', { username: targetUser.username })
"
size="tiny"
:style="{ minWidth: statusBtnMinWidth }"
@click="$emit('verifiedClick', targetUser)"
>
{{
targetUser.isVerified ? t('models.user.isVerified') : t('models.user.isUnverified')
targetUser.isVerified ? $t('models.user.isVerified') : $t('models.user.isUnverified')
}}
<template #icon>
<n-icon :component="targetUser.isVerified ? VerifiedUserRound : QuestionMarkRound" />
Expand All @@ -112,7 +110,7 @@ const statusBtnMinWidth = '128px';
strong
secondary
type="error"
:title="t('admin.users.statusBtnTitle.deleteUser', { username: targetUser.username })"
:title="$t('admin.users.statusBtnTitle.deleteUser', { username: targetUser.username })"
size="tiny"
:disabled="currentUser && currentUser.id === targetUser.id"
@click="$emit('deleteClick', targetUser)"
Expand Down
16 changes: 7 additions & 9 deletions Tekst-Web/src/components/browse/BrowseLocationControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import router from '@/router';
import ModalButtonFooter from '@/components/ModalButtonFooter.vue';
import { useMagicKeys, whenever } from '@vueuse/core';
import { useApi } from '@/api';
import { useI18n } from 'vue-i18n';
const state = useStateStore();
const browse = useBrowseStore();
const route = useRoute();
const { t } = useI18n({ useScope: 'global' });
const { browseApi } = useApi();
const { ArrowLeft, ArrowRight } = useMagicKeys();
Expand Down Expand Up @@ -221,7 +219,7 @@ whenever(ArrowLeft, () => {
@click="navigate"
:disabled="browse.position === 0"
:focusable="false"
:title="t('browse.toolbar.tipPreviousLocation')"
:title="$t('browse.toolbar.tipPreviousLocation')"
size="large"
color="#fff"
>
Expand All @@ -233,7 +231,7 @@ whenever(ArrowLeft, () => {

<n-button
secondary
:title="t('browse.toolbar.tipSelectLocation')"
:title="$t('browse.toolbar.tipSelectLocation')"
@click="showModal = true"
:focusable="false"
size="large"
Expand All @@ -250,7 +248,7 @@ whenever(ArrowLeft, () => {
secondary
@click="navigate"
:focusable="false"
:title="t('browse.toolbar.tipNextLocation')"
:title="$t('browse.toolbar.tipNextLocation')"
size="large"
color="#fff"
>
Expand All @@ -271,14 +269,14 @@ whenever(ArrowLeft, () => {
size="large"
class="tekst-modal"
>
<h2>{{ t('browse.location.modalHeading') }}</h2>
<h2>{{ $t('browse.location.modalHeading') }}</h2>
<n-form
label-placement="left"
label-width="auto"
:show-feedback="false"
:show-require-mark="false"
>
<n-form-item :label="t('browse.location.level')">
<n-form-item :label="$t('browse.location.level')">
<n-select :options="browseLevelOptions" v-model:value="browseLevel" />
</n-form-item>

Expand All @@ -305,10 +303,10 @@ whenever(ArrowLeft, () => {
<!-- <pre style="font-size: 11px; line-height: 1">{{ locationSelectModels }}</pre> -->
<ModalButtonFooter>
<n-button @click="showModal = false" :focusable="false">
{{ t('general.cancelAction') }}
{{ $t('general.cancelAction') }}
</n-button>
<n-button type="primary" @click="handleLocationSelect">
{{ t('general.selectAction') }}
{{ $t('general.selectAction') }}
</n-button>
</ModalButtonFooter>
</n-modal>
Expand Down
6 changes: 2 additions & 4 deletions Tekst-Web/src/components/browse/BrowseToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import CompressRound from '@vicons/material/CompressRound';
import ExpandRound from '@vicons/material/ExpandRound';
import LayersRound from '@vicons/material/LayersRound';
import { useBrowseStore, useStateStore } from '@/stores';
import { useI18n } from 'vue-i18n';
const state = useStateStore();
const browse = useBrowseStore();
const { t } = useI18n({ useScope: 'global' });
const affixRef = ref(null);
Expand Down Expand Up @@ -41,7 +39,7 @@ onMounted(() => {
:secondary="!browse.reducedView"
:ghost="browse.reducedView"
size="large"
:title="t('browse.toolbar.tipReducedView')"
:title="$t('browse.toolbar.tipReducedView')"
color="#fff"
:focusable="false"
@click="browse.reducedView = !browse.reducedView"
Expand All @@ -55,7 +53,7 @@ onMounted(() => {
<n-button
secondary
size="large"
:title="t('browse.toolbar.tipOpenDataLayerList')"
:title="$t('browse.toolbar.tipOpenDataLayerList')"
color="#fff"
:focusable="false"
@click="browse.showLayerToggleDrawer = true"
Expand Down
4 changes: 1 addition & 3 deletions Tekst-Web/src/components/browse/LayerToggleDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import { computed } from 'vue';
import { NDrawer, NDrawerContent } from 'naive-ui';
import { useBrowseStore } from '@/stores';
import LayerToggleDrawerItem from '@/components/browse/LayerToggleDrawerItem.vue';
import { useI18n } from 'vue-i18n';
const props = defineProps<{ show: boolean }>();
const emits = defineEmits<{ (e: 'update:show', show: boolean): void }>();
const browse = useBrowseStore();
const { t } = useI18n({ useScope: 'global' });
const show = computed({
get() {
Expand All @@ -30,7 +28,7 @@ const show = computed({
style="max-width: 90%"
>
<n-drawer-content
:title="t('browse.layerToggleDrawer.heading')"
:title="$t('browse.layerToggleDrawer.heading')"
header-style="font-size: var(--app-ui-font-size-huge); font-weight: var(--app-ui-font-weight-light)"
closable
>
Expand Down
2 changes: 1 addition & 1 deletion Tekst-Web/src/components/browse/LayerToggleDrawerItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const infoTooltip = computed(() => (props.disabled ? t('browse.locationLayerNoDa
<div class="layer-toggle-item-title-container">
<div class="layer-toggle-item-title">{{ layer.title }}</div>
<div class="layer-toggle-item-title-extra">
({{ t('browse.location.level') }}: {{ state.textLevelLabels[layer.level] }})
({{ $t('browse.location.level') }}: {{ state.textLevelLabels[layer.level] }})
</div>
</div>
<div class="layer-toggle-item-meta">
Expand Down
4 changes: 1 addition & 3 deletions Tekst-Web/src/components/browse/widgets/DeepLLinksWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { VNodeChild } from 'vue';
import { useStateStore } from '@/stores';
import { NDropdown } from 'naive-ui';
import type { DropdownOption } from 'naive-ui';
import { useI18n } from 'vue-i18n';
const DEEPL_TRANSLATOR_URL = 'https://www.deepl.com/translator';
Expand All @@ -17,7 +16,6 @@ const props = defineProps<{
}>();
const state = useStateStore();
const { t } = useI18n({ useScope: 'global' });
const unitsTextEncoded = computed<string>(() => {
const unitsText = props.layer.units
Expand Down Expand Up @@ -65,7 +63,7 @@ function renderOption(option: DropdownOption) {
show-arrow
>
<UnitContainerHeaderWidget
:title="t('browse.units.widgets.deepLTranslate.title')"
:title="$t('browse.units.widgets.deepLTranslate.title')"
:iconComponent="TranslateRound"
/>
</n-dropdown>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function handleClick() {

<template>
<UnitContainerHeaderWidget
:title="t('browse.units.widgets.deactivateWidget.title')"
:title="$t('browse.units.widgets.deactivateWidget.title')"
:iconComponent="ClearRound"
@click="handleClick"
/>
Expand Down
Loading

0 comments on commit 3f66d31

Please sign in to comment.