Skip to content

Commit

Permalink
add i18n for clubs payments in default-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
aggre committed Jul 15, 2024
1 parent 95fb5f3 commit 5cbb4f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { bytes32Hex } from '@devprotocol/clubs-core'
import type { ComposedItem } from '@plugins/clubs-payments'
import { createPath } from '@plugins/clubs-payments/utils/create-path'
import type { Membership } from '@plugins/memberships'
import { i18nFactory } from '@devprotocol/clubs-core'
import { Strings } from '../../i18n'
type Props = {
memberships: Membership[]
Expand All @@ -13,6 +15,13 @@ type Props = {
const { memberships, name, overrides } = Astro.props
const i18nBase = i18nFactory(Strings)
const langs = Astro.request.headers
.get('accept-language')
?.replace(/;q=[\d\.]+/g, '')
.split(',') ?? ['en']
const i18n = i18nBase(langs)
const find = (
membership: Membership,
): { membership: Membership; override?: ComposedItem } => {
Expand All @@ -39,7 +48,7 @@ const find = (
name={membership.name}
price={String(override?.price.yen || membership.price)}
currency={membership.currency}
nonStandardCurrency={override?.price.yen ? 'YEN' : undefined}
nonStandardCurrency={override?.price.yen ? i18n('JPY') : undefined}
description={membership.description}
imagePath={membership.imageSrc}
action={
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/default-theme/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ export const Strings = {
en: ([name]) => `About ${name}`,
ja: ([name]) => `${name} について`,
},
JPY: {
en: 'JPY',
ja: '円',
},
} satisfies ClubsI18nParts

0 comments on commit 5cbb4f4

Please sign in to comment.