Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: i18n $t return string type #5129

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/carousel/CarouselTypeLatestSales.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<CarouselIndex
data-cy="latest-sales"
:title="`${$t('general.latestSales')}`"
:title="$t('general.latestSales')"
:subtitle="`${$t('general.latestSalesheading')} ${urlPrefix}`"
:nfts="nfts"
action-type="pagination" />
Expand Down
4 changes: 2 additions & 2 deletions components/carousel/CarouselTypeNewestList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<CarouselIndex
:title="`${$t('general.newestListHeading')}`"
:subtitle="`${$t('general.newestListDesc')}`"
:title="$t('general.newestListHeading')"
:subtitle="$t('general.newestListDesc')"
:nfts="nfts"
action-type="link"
:link-url="`/${urlPrefix}/explore/items/?search=&sort=updatedAt_DESC`"
Expand Down
4 changes: 2 additions & 2 deletions components/carousel/CarouselTypePopularCollection.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<CarouselIndex
:title="`${$t('general.popularCollectionsHeading')}`"
:subtitle="`${$t('general.popularCollectionsDesc')}`"
:title="$t('general.popularCollectionsHeading')"
:subtitle="$t('general.popularCollectionsDesc')"
:nfts="nfts"
action-type="pagination"
item-url="collection" />
Expand Down
2 changes: 1 addition & 1 deletion components/carousel/CarouselTypeSpotlight.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<CarouselIndex
:key="spotlight.length && spotlight[0].id"
:title="`${$t('spotlight.page')}`"
:title="$t('spotlight.page')"
:nfts="spotlight"
action-type="pagination"
item-url="collection" />
Expand Down
4 changes: 2 additions & 2 deletions components/gallery/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
<IdentityItem
v-if="nft?.issuer"
class="gallery-avatar mr-4"
:label="`${$t('Creator')}`"
:label="$t('Creator')"
:prefix="urlPrefix"
:account="nft?.issuer"
data-cy="item-creator" />
<IdentityItem
v-if="nft?.currentOwner !== nft?.issuer"
class="gallery-avatar"
:label="`${$t('Owner')}`"
:label="$t('Owner')"
:prefix="urlPrefix"
:account="nft?.currentOwner || ''"
data-cy="item-owner" />
Expand Down
4 changes: 1 addition & 3 deletions components/shared/Support.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<b-switch v-model="model" :type="type" :rounded="false">
<div class="is-flex is-align-items-center">
<span class="mr-2">
{{
value ? `${$t(activeMessage)}${priceString}` : `${$t(passiveMessage)}`
}}
{{ value ? `${$t(activeMessage)}${priceString}` : $t(passiveMessage) }}
</span>
<slot name="tooltip" />
</div>
Expand Down
24 changes: 24 additions & 0 deletions vue-i18n.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import VueI18n, { Locale, Path, Values } from 'vue-i18n/types'

/**
* Overloads VueI18n interface to avoid needing to cast return value to string.
* @see https://github.com/kazupon/vue-i18n/issues/410
*/
declare module 'vue-i18n/types' {
export default class VueI18n {
t(key: Path, locale: Locale, values?: Values): string
t(key: Path, values?: Values): string
}
}

declare module 'vue/types/vue' {
interface Vue {
$t: typeof VueI18n.prototype.t
}

interface VueConstructor<V extends Vue = Vue> {
i18n: typeof VueI18n.prototype
}
}

export default VueI18n