Skip to content

Open source personal finance application

refactor(i18n): replace $t with t, add useI18n

Ilya Komicheva780b98b6a78
diff --git a/app/components/layout/ConfirmModal.vue b/app/components/layout/ConfirmModal.vue
index 405ac87e..4a6871ae 100644
--- a/app/components/layout/ConfirmModal.vue
+++ b/app/components/layout/ConfirmModal.vue
@@ -71,7 +71,7 @@ const items = computed(() => ({
/>
</template>
- {{ $t(item.localeKey) }}
+ {{ t(item.localeKey) }}
</UiElement>
</div>
</div>
diff --git a/app/components/stat/Item.vue b/app/components/stat/Item.vue
index b0b31aae..755b5194 100644
--- a/app/components/stat/Item.vue
+++ b/app/components/stat/Item.vue
@@ -336,7 +336,7 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {
<div class="bottomSheetContent">
<UiTitleModal>
- {{ $t('trns.title') }} {{ quickViewTrns.length > 0 ? quickViewTrns.length : '' }}
+ {{ t('trns.title') }} {{ quickViewTrns.length > 0 ? quickViewTrns.length : '' }}
</UiTitleModal>
<div class="scrollerBlock bottomSheetContentInside pb-2">
@@ -371,7 +371,7 @@ function getIntervalsData(trnsIds: TrnId[], intervalsInRange: Range[]) {
<div class="bottomSheetContent">
<UiTitleModal>
- {{ $t('trns.title') }} {{ selectedAndFilteredTrnsIds.length > 0 ? selectedAndFilteredTrnsIds.length : '' }}
+ {{ t('trns.title') }} {{ selectedAndFilteredTrnsIds.length > 0 ? selectedAndFilteredTrnsIds.length : '' }}
</UiTitleModal>
<div class="scrollerBlock bottomSheetContentInside">
diff --git a/app/components/stat/sum/Item.vue b/app/components/stat/sum/Item.vue
index d6cdeb6f..f65dae85 100644
--- a/app/components/stat/sum/Item.vue
+++ b/app/components/stat/sum/Item.vue
@@ -38,8 +38,8 @@ const currenciesStore = useCurrenciesStore()
</UiTitle6>
<UiTitle6 v-if="!props.title">
- {{ props.isTotal ? $t('money.all') : '' }}
- {{ $t(`money.${props.type}`) }}
+ {{ props.isTotal ? t('money.all') : '' }}
+ {{ t(`money.${props.type}`) }}
</UiTitle6>
<Amount
diff --git a/app/components/trnForm/Categories.vue b/app/components/trnForm/Categories.vue
index 5e4ad66f..32f15c96 100644
--- a/app/components/trnForm/Categories.vue
+++ b/app/components/trnForm/Categories.vue
@@ -11,6 +11,7 @@ const emit = defineEmits<{
(e: 'click', id: CategoryId): void
}>()
+const { t } = useI18n()
const trnsFormStore = useTrnsFormStore()
const categoriesStore = useCategoriesStore()
@@ -48,7 +49,7 @@ onMounted(() => {
<div
class="scrollerBlock font-primary rounded-t-2xl bg-[var(--item-1)] px-3 py-4 text-center text-xl font-semibold"
>
- {{ $t('categories.recentCategories') }}
+ {{ t('categories.recentCategories') }}
</div>
<div class="px-3 pb-1">
<CategoriesList
@@ -65,7 +66,7 @@ onMounted(() => {
<div
class="scrollerBlock font-primary rounded-t-2xl bg-[var(--item-1)] px-3 py-4 text-center text-xl font-semibold"
>
- {{ $t('categories.title') }}
+ {{ t('categories.title') }}
</div>
<div class="px-3 pb-1">
<CategoriesList
@@ -80,7 +81,7 @@ onMounted(() => {
<!-- Favorite -->
<div class="swiper-slide h-full">
<div class="scrollerBlock font-primary rounded-t-2xl bg-[var(--item-1)] px-3 py-4 text-center text-xl font-semibold">
- {{ $t('categories.favoriteCategories') }}
+ {{ t('categories.favoriteCategories') }}
</div>
<div class="px-3 pb-1">
<CategoriesList
@@ -101,21 +102,21 @@ onMounted(() => {
:isActive="sliderObj.activeIndex === 0"
@click="sliderObj.slideTo(0)"
>
- {{ $t('categories.recentCategories') }}
+ {{ t('categories.recentCategories') }}
</UiTabsItem1>
<UiTabsItem1
:isActive="sliderObj.activeIndex === 1"
@click="sliderObj.slideTo(1)"
>
- {{ $t('categories.allTitle') }}
+ {{ t('categories.allTitle') }}
</UiTabsItem1>
<UiTabsItem1
:isActive="sliderObj.activeIndex === 2"
@click="sliderObj.slideTo(2)"
>
- {{ $t('categories.favoriteCategories') }}
+ {{ t('categories.favoriteCategories') }}
</UiTabsItem1>
</UiTabs1>
</div>
diff --git a/app/components/trnForm/Selection.vue b/app/components/trnForm/Selection.vue
index 8cabed6c..107bf1dc 100644
--- a/app/components/trnForm/Selection.vue
+++ b/app/components/trnForm/Selection.vue
@@ -26,6 +26,7 @@ const isShow = defineModel('isShow', {
default: false,
})
+const { t } = useI18n()
const categoriesStore = useCategoriesStore()
const trnsFormStore = useTrnsFormStore()
@@ -120,7 +121,7 @@ async function onSelectParentCategory(id: CategoryId) {
class="sticky top-0 z-10 bg-[var(--item-1)] px-3 pt-4 pb-3"
@click="trnsFormStore.ui.catsRootModal = true"
>
- {{ $t('categories.title') }}
+ {{ t('categories.title') }}
</UiTitle3>
<CategoriesSelector
@onSelected="id => onSelectCategory(id, close)"
diff --git a/app/components/trnForm/SelectionWalletsAll.vue b/app/components/trnForm/SelectionWalletsAll.vue
index 5a29e7c2..21e5c0ef 100644
--- a/app/components/trnForm/SelectionWalletsAll.vue
+++ b/app/components/trnForm/SelectionWalletsAll.vue
@@ -11,13 +11,14 @@ const emit = defineEmits<{
onSelectWallet: [id: WalletId]
}>()
+const { t } = useI18n()
const trnsFormStore = useTrnsFormStore()
</script>
<template>
<div>
<UiTitleModal @click="trnsFormStore.ui.walletsModal = true">
- {{ $t('wallets.title') }}
+ {{ t('wallets.title') }}
</UiTitleModal>
<WalletsSelector
diff --git a/app/components/trnForm/main/Types.vue b/app/components/trnForm/main/Types.vue
index ebe7c2dd..306b6060 100644
--- a/app/components/trnForm/main/Types.vue
+++ b/app/components/trnForm/main/Types.vue
@@ -4,6 +4,7 @@ import type { TrnType } from '~/components/trns/types'
import { useTrnsFormStore } from '~/components/trnForm/useTrnsFormStore'
import { useWalletsStore } from '~/components/wallets/useWalletsStore'
+const { t } = useI18n()
const trnsFormStore = useTrnsFormStore()
const walletsStore = useWalletsStore()
@@ -22,14 +23,14 @@ function isItActive(amountType: TrnType) {
:isActive="isItActive(0)"
@click="setAmountType(0)"
>
- {{ $t('money.expense') }}
+ {{ t('money.expense') }}
</UiTabsItem3>
<UiTabsItem3
:isActive="isItActive(1)"
@click="setAmountType(1)"
>
- {{ $t('money.income') }}
+ {{ t('money.income') }}
</UiTabsItem3>
<UiTabsItem3
@@ -37,7 +38,7 @@ function isItActive(amountType: TrnType) {
:isActive="isItActive(2)"
@click="setAmountType(2)"
>
- {{ $t('trnForm.transferTitle') }}
+ {{ t('trnForm.transferTitle') }}
</UiTabsItem3>
</UiTabs1>
</template>
diff --git a/app/components/trns/NoTrns.vue b/app/components/trns/NoTrns.vue
index 43ecb01a..4ceb5240 100644
--- a/app/components/trns/NoTrns.vue
+++ b/app/components/trns/NoTrns.vue
@@ -1,8 +1,12 @@
+<script setup lang="ts">
+const { t } = useI18n()
+</script>
+
<template>
<div class="flex-center text-muted flex gap-2 py-3 text-center">
<Icon name="lucide:tree-palm" size="22" />
<div class="text-base leading-none">
- {{ $t('trns.noTrns') }}
+ {{ t('trns.noTrns') }}
</div>
</div>
</template>
diff --git a/app/components/ui/Logo.vue b/app/components/ui/Logo.vue
index 5ff85ab4..cbeb3a29 100644
--- a/app/components/ui/Logo.vue
+++ b/app/components/ui/Logo.vue
@@ -1,5 +1,9 @@
+<script setup lang="ts">
+const { t } = useI18n()
+</script>
+
<template>
<div class="font-brand first-letter:text-primary text-2xl font-bold">
- {{ $t('appName') }}
+ {{ t('appName') }}
</div>
</template>
diff --git a/app/components/wallets/Statistics.vue b/app/components/wallets/Statistics.vue
index 756854dd..4a074cd9 100644
--- a/app/components/wallets/Statistics.vue
+++ b/app/components/wallets/Statistics.vue
@@ -57,7 +57,7 @@ const itemsGrouped = computed(() => [
>
<div class="text-muted grow pl-1 text-sm leading-none">
<div>
- {{ $t(`money.types.${item.id}`) }}
+ {{ t(`money.types.${item.id}`) }}
</div>
<div