Skip to content
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
18 changes: 5 additions & 13 deletions apps/web/app/components/SponsorPageSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@
import { useI18n } from '#i18n'
import { useRuntimeConfig } from '#imports'
import { useColor, useTypography } from '@vuejs-jp/composable'
import { useLocaleCurrent } from '@/composables/useLocaleCurrent'
import { useTranslation } from '@/composables/useTranslation'

const config = useRuntimeConfig()
const { fontWeight, fontSize } = useTypography()
const { color } = useColor()

const { t, te } = useI18n()
const { locale } = useLocaleCurrent()
/**
* Get translation or return empty string
* @param key - translation key
* @returns translation or empty string
*/
function getTranslationOrDefault(key: string): string {
return te(key, locale.value) ? t(key) : ''
}
const { t } = useI18n()
const { translate } = useTranslation()

const periodStart = {
prefixYear: t('prefix_year'),
date: t('sponsor.start_date'),
dayOfWeek: getTranslationOrDefault('day_of_week.monday'),
dayOfWeek: translate('day_of_week.monday'),
}

// const periodEnd = {
// suffixYear: t('suffix_year'),
// date: t('sponsor.end_date'),
// dayOfWeek: getTranslationOrDefault('day_of_week.thursday'),
// dayOfWeek: translate('day_of_week.thursday'),
// }
</script>

Expand Down
18 changes: 18 additions & 0 deletions apps/web/app/composables/useTranslation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useI18n } from '#i18n'
import { useLocaleCurrent } from '@/composables/useLocaleCurrent'

export function useTranslation() {
const { t, te } = useI18n()
const { locale } = useLocaleCurrent()
function translate(key: string) {
return te(key, locale.value) ? t(key) : ''
}

return {
/**
* return translation or empty string
* https://github.com/vuejs-jp/vuefes-2024/pull/136#discussion_r1597312717
*/
translate
}
}