Skip to content

Commit

Permalink
refactor(i18n): replace useI18n() with useTranslation()
Browse files Browse the repository at this point in the history
This will enable `autocomplete` for `translations` to improve `dx`.
And wraps `third party` code for better `maintainability`.

See: BEDS-97
  • Loading branch information
MarcelBitfly committed Aug 6, 2024
1 parent 575f079 commit c717308
Show file tree
Hide file tree
Showing 83 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion frontend/components/bc/BcFaq.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {
translationPath?: string
}
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const questions = computed(() => {
const list = []
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/BcMaintenanceBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { warn } from 'vue'
const { public: { maintenanceTS } } = useRuntimeConfig()
const { tick } = useInterval(60)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const maintenanceLabel = computed(() => {
if (!maintenanceTS) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/CookieModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { COOKIE_KEY, type CookiesPreference } from '~/types/cookie'
import { Target } from '~/types/links'
const cookiePreference = useCookie<CookiesPreference>(COOKIE_KEY.COOKIES_PREFERENCE, { default: () => undefined })
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const setCookiePreference = (value: CookiesPreference) => {
cookiePreference.value = value
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/CopyToClipboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
}
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { value: tooltip, bounce, instant } = useDebounceValue<string>($t('clipboard.copy'), 2000)
function copyToClipboard (): void {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/dialog/BcDialogConfirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Props {
severity?: 'default' | 'danger'
}
const { props, dialogRef } = useBcDialog<Props>({ showHeader: false })
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const noLabel = computed(() => props.value?.noLabel || $t('navigation.no'))
const yesLabel = computed(() => props.value?.yesLabel || $t('navigation.yes'))
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/footer/LinkList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Target } from '~/types/links'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
type Row = { title: string, links: [string, IconDefinition, string, Target][] }
const columns: Row[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/format/FormatTimePassed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
unitLength?: StringUnitLength
}
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { timestamp } = useDate()
const { setting } = useGlobalSetting<AgeFormat>('age-format')
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/header/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { slotToEpoch, currentNetwork, networkInfo } = useNetworkStore()
const { doLogout, isLoggedIn } = useUserStore()
const { currency, available, rates } = useCurrency()
const { width } = useWindowSize()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const colorMode = useColorMode()
const isSmallScreen = computed(() => width.value < smallHeaderThreshold)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/header/MegaMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import IconWebhook from '~/components/icon/megaMenu/WebHook.vue'
import { Target } from '~/types/links'
import { mobileHeaderThreshold, smallHeaderThreshold } from '~/types/header'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { width } = useWindowSize()
const { doLogout, isLoggedIn } = useUserStore()
const route = useRoute()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/premium/BcPremiumModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface Props {
}
const { props, dialogRef, setHeader } = useBcDialog<Props>({ contentClass: 'premium-modal' })
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const hide = () => {
dialogRef?.value.close()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/searchbar/CategorySelectors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defineProps<{
}>()
const liveState = defineModel<CategoryFilter>({ required: true }) // each entry has a Category as key and the state of the option as value. The component will write directly into it, so the data of the parent is always up-to-date.
const { t } = useI18n()
const { t } = useTranslation()
function selectionHasChanged (category : Category, selected : boolean) {
liveState.value.set(category, selected)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/searchbar/NetworkSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defineProps<{
}>()
const liveState = defineModel<NetworkFilter>({ required: true }) // each entry has a ChainIDs as key and the state of the option as value. The component will write directly into it, so the data of the parent is always up-to-date.
const { t } = useI18n()
const { t } = useTranslation()
const headState = ref<{look : 'on'|'off', network : string}>({
look: 'off',
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/searchbar/SearchbarMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const dropdownLayout = ref<SearchbarDropdownLayout>('narrow-dropdown')
defineExpose<ExposedSearchbarMethods>({ hideResult, closeDropdown, empty })
const { t } = useI18n()
const { t } = useTranslation()
const { fetch } = useCustomFetch()
const { availableNetworks } = useNetworkStore()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/searchbar/SuggestionRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const props = defineProps<{
screenWidthCausingSuddenChange: number
}>()
const { t } = useI18n()
const { t } = useTranslation()
function formatSubcategoryCell () : string {
const i18nPathOfSubcategoryTitle = getI18nPathOfTranslatableLitteral(SubCategoryInfo[TypeInfo[props.suggestion.type].subCategory].title)
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/bc/table/BcTableValidTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface Props {
}
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const data = computed<{color: TagColor, label: string}>(() => {
return {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/block/table/BlockTableStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
}
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { latestState } = useLatestStateStore()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/DashboardControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { isLoggedIn } = useUserStore()
const { dashboardKey, isPublic, isPrivate, isShared, setDashboardKey, dashboardType, publicEntities } = useDashboardKey()
const { refreshDashboards, dashboards, getDashboardLabel, updateHash } = useUserDashboardStore()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { width } = useWindowSize()
const dialog = useDialog()
const { fetch } = useCustomFetch()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/DashboardHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Props {
}
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const route = useRoute()
const router = useRouter()
const isValidatorDashboard = route.name === 'dashboard-id'
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/DashboardRenameModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DashboardType } from '~/types/dashboard'
import { API_PATH } from '~/types/customFetch'
import type { ValidatorDashboard } from '~/types/api/dashboard'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { fetch } = useCustomFetch()
const name = defineModel<string>('name', { default: '' })
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/DashboardShareCodeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
dashboard?: ValidatorDashboard; // Currently only validator dashboards are supported. For public dashboards this will be undefined
}
const { props, dialogRef } = useBcDialog<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const router = useRouter()
const url = useRequestURL()
const { refreshDashboards } = useUserDashboardStore()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/DashboardShareModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
dashboard: ValidatorDashboard; // Currently only validator dashboards are supported
}
const { props, dialogRef } = useBcDialog<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { refreshDashboards } = useUserDashboardStore()
const { fetch } = useCustomFetch()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/GroupManagementModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { Cursor, SortOrder } from '~/types/datatable'
import { getSortOrder } from '~/utils/table'
import { API_PATH } from '~/types/customFetch'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { fetch } = useCustomFetch()
const dialog = useDialog()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/SharedDashboardModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { COOKIE_KEY, type CookiesPreference } from '~/types/cookie'
const cookiePreference = useCookie<CookiesPreference>(COOKIE_KEY.COOKIES_PREFERENCE, { default: () => undefined })
const { isShared } = useDashboardKey()
const { dashboards } = useUserDashboardStore()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const route = useRoute()
const dismissed = ref(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ValidatorHistoryDuties } from '~/types/api/common'
import type { PathValues } from '~/types/customFetch'
import { API_PATH } from '~/types/customFetch'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { fetch } = useCustomFetch()
const { width } = useWindowSize()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/ValidatorManagementModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { type SearchBar, SearchbarShape, SearchbarColors, SearchbarPurpose, type
import { API_PATH, type PathValues } from '~/types/customFetch'
import { useNetworkStore } from '~/stores/useNetworkStore'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { fetch } = useCustomFetch()
const { currentNetwork } = useNetworkStore()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/ValidatorOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type OverviewTableData } from '~/types/dashboard/overview'
import { TimeFrames, type NumberOrString } from '~/types/value'
import { totalElClNumbers } from '~/utils/bigMath'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { converter } = useValue()
const tPath = 'dashboard.validator.overview.'
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/ValidatorSlotViz.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { orderBy } from 'lodash-es'
import { useValidatorSlotVizStore } from '~/stores/dashboard/useValidatorSlotVizStore'
import { getGroupLabel } from '~/utils/dashboard/group'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { dashboardKey } = useDashboardKey()
const { validatorCount, overview } = useValidatorDashboardOverviewStore()
const { networkInfo } = useNetworkStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { orderBy } from 'lodash-es'
import { type AggregationTimeframe, AggregationTimeframes, type EfficiencyType, EfficiencyTypes, SUMMARY_CHART_GROUP_NETWORK_AVERAGE, SUMMARY_CHART_GROUP_TOTAL, type SummaryChartFilter } from '~/types/dashboard/summary'
import { getGroupLabel } from '~/utils/dashboard/group'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { overview } = useValidatorDashboardOverviewStore()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/chart/RewardsChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ await useAsyncData('validator_dashboard_rewards_chart', async () => {
const { groups } = useValidatorDashboardGroups()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const colorMode = useColorMode()
const { converter } = useValue()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/chart/SummaryChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Props {
const props = defineProps<Props>()
const chart = ref<ECharts | undefined>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const colorMode = useColorMode()
const { fetch } = useCustomFetch()
const { tsToEpoch, slotToTs, secondsPerEpoch } = useNetworkStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChainInfo, type ChainIDs, isL1 } from '~/types/network'
import { useNetworkStore } from '~/stores/useNetworkStore'
const { currentNetwork, availableNetworks, isNetworkDisabled } = useNetworkStore()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const emit = defineEmits<{(e: 'next' | 'back'): void }>()
const network = defineModel<ChainIDs>('network', { required: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { type DashboardType } from '~/types/dashboard'
import { IconAccount, IconValidator } from '#components'
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { isLoggedIn } = useUserStore()
interface Props {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/group/GroupLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Props {
const props = defineProps<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const name = computed(() => {
if (props.group.id === DAHSHBOARDS_ALL_GROUPS_ID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {
totalValidators?: number
}
const { props, setHeader, dialogRef } = useBcDialog<Props>()
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const selectedGroupId = ref<number>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { dashboardKey, isPublic } = useDashboardKey()
const cursor = ref<Cursor>()
const pageSize = ref<number>(10)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { blocks, query: lastQuery, isLoading, getBlocks } = useValidatorDashboardBlocksStore()
const { value: query, temp: tempQuery, bounce: setQuery } = useDebounceValue<TableQueryParams | undefined>(undefined, 500)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { dashboardKey } = useDashboardKey()
const cursor = ref<Cursor>()
const pageSize = ref<number>(5)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { slotToEpoch } = useNetworkStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { dashboardKey } = useDashboardKey()
const cursor = ref<Cursor>()
const pageSize = ref<number>(5)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { deposits, query: lastQuery, getDeposits, getTotalAmount, totalAmount, isLoadingDeposits, isLoadingTotal } = useValidatorDashboardElDepositsStore()
const { value: query, bounce: setQuery } = useDebounceValue<TableQueryParams | undefined>(undefined, 500)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { dashboardKey, isPublic } = useDashboardKey()
const cursor = ref<Cursor>()
const pageSize = ref<number>(10)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const showInDevelopment = Boolean(useRuntimeConfig().public.showInDevelopment)
const { rewards, query: lastQuery, isLoading, getRewards } = useValidatorDashboardRewardsStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const props = defineProps<Props>()

const { dashboardKey } = useDashboardKey()

const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { details } = useValidatorDashboardRewardsDetailsStore(dashboardKey.value, props.row.group_id, props.row.epoch)

const dialog = useDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { dashboardKey, isPublic } = useDashboardKey()

const cursor = ref<Cursor>()
const pageSize = ref<number>(10)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const chartFilter = ref<SummaryChartFilter>({ aggregation: 'hourly', efficiency: 'all', groupIds: [] })

const { summary, query: lastQuery, isLoading, getSummary } = useValidatorDashboardSummaryStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {
}
const props = defineProps<Props>()

const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { groups } = useValidatorDashboardGroups()

const dialog = useDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { dashboardKey } = useDashboardKey()

const cursor = ref<Cursor>()
const pageSize = ref<number>(10)
const { t: $t } = useI18n()
const { t: $t } = useTranslation()

const { latestState } = useLatestStateStore()
const { slotToEpoch } = useNetworkStore()
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/table/SummaryDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const props = defineProps<Props>()

const { dashboardKey } = useDashboardKey()

const { t: $t } = useI18n()
const { t: $t } = useTranslation()
const { details: summary, getDetails } = useValidatorDashboardSummaryDetailsStore(dashboardKey.value, props.row.group_id)

watch(() => props.timeFrame, () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/dashboard/table/SummaryStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Props {
}
const props = defineProps<Props>()

const { t: $t } = useI18n()
const { t: $t } = useTranslation()

const mapped = computed(() => {
const mapCount = (count: number, key: string, icon: SlotVizIcons) => {
Expand Down
Loading

0 comments on commit c717308

Please sign in to comment.