Skip to content

Commit bb4249a

Browse files
committed
add locale for payload.findGlobal
1 parent 3e287b7 commit bb4249a

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

messages/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"posts": "Posts",
44
"join_the_discussion_on_github": "Join the discussion on GitHub",
55
"author": "Author",
6-
"date_published": "Date Published",
6+
"published_at": "Published At",
77
"source": "Source",
88
"pagination": "Showing {start} - {end} of {total, plural, one {# Post} other {# Posts}}",
99
"pagination_0": "Showing 0 of {total, plural, one {# Post} other {# Posts}}",

messages/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"posts": "文章",
44
"join_the_discussion_on_github": "在 GitHub 参与讨论",
55
"author": "作者",
6-
"date_published": "发布日期",
6+
"published_at": "发布时间",
77
"source": "数据来源",
88
"pagination": "显示第 {start} - {end} 条,共 {total} 条",
99
"pagination_0": "显示 0 条,共 {total} 条",

src/heros/PostHero/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const PostHero: React.FC<{
5858
)}
5959
{publishedAt && (
6060
<div className="flex flex-col gap-1">
61-
<p className="text-sm">{t('date_published')}</p>
61+
<p className="text-sm">{t('published_at')}</p>
6262

6363
<time dateTime={publishedAt}>
6464
<LocalTime time={publishedAt} />

src/utilities/getGlobals.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import configPromise from '@payload-config'
44
import { getPayload } from 'payload'
55
import { unstable_cache } from 'next/cache'
66

7+
import { getLocale } from 'next-intl/server'
8+
import { Locale } from '@/i18n/types'
9+
710
type Global = keyof Config['globals']
811

912
async function getGlobal(slug: Global, depth = 0) {
13+
const locale = (await getLocale()) as Locale
14+
1015
const payload = await getPayload({ config: configPromise })
1116

1217
const global = await payload.findGlobal({
1318
slug,
1419
depth,
20+
locale,
1521
})
1622

1723
return global

0 commit comments

Comments
 (0)