Skip to content

Commit 68cc216

Browse files
Saturn226heiskr
andauthored
copilot cookbook: use template strings for ui elements (#53491)
Co-authored-by: Kevin Heis <[email protected]>
1 parent b15eaa9 commit 68cc216

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

data/ui.yml

+7
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,10 @@ domain_edit:
311311
snippet_about: Updating will include the new domain name in all code snippets across GitHub Docs.
312312
learn_more: Learn more
313313
submission_failed: Submission failed. Please try again in a minute.
314+
cookbook_landing:
315+
spotlight: Spotlight
316+
explore_articles: Explore {{ number }} prompt articles
317+
reset_filters: Reset filters
318+
search_articles: Search articles
319+
category: Category
320+
complexity: Complexity

src/fixtures/fixtures/data/ui.yml

+7
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,10 @@ domain_edit:
311311
snippet_about: Updating will include the new domain name in all code snippets across GitHub Docs.
312312
learn_more: Learn more
313313
submission_failed: Submission failed. Please try again in a minute.
314+
cookbook_landing:
315+
spotlight: Spotlight
316+
explore_articles: Explore {{ number }} prompt articles
317+
reset_filters: Reset filters
318+
search_articles: Search articles
319+
category: Category
320+
complexity: Complexity

src/frame/components/context/MainContext.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ const DEFAULT_UI_NAMESPACES = [
150150
'support',
151151
'rest',
152152
'domain_edit',
153+
'cookbook_landing',
153154
]
154155

155156
export function addUINamespaces(req: any, ui: UIStrings, namespaces: string[]) {

src/landings/components/CategoryLanding.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
33
import cx from 'classnames'
44
import { CookBookArticleCard } from './CookBookArticleCard'
55
import { CookBookFilter } from './CookBookFilter'
6-
6+
import { useTranslation } from 'src/languages/components/useTranslation'
77
import { DefaultLayout } from 'src/frame/components/DefaultLayout'
88
import { ArticleTitle } from 'src/frame/components/article/ArticleTitle'
99
import { Lead } from 'src/frame/components/ui/Lead'
@@ -14,6 +14,7 @@ import { Breadcrumbs } from 'src/frame/components/page-header/Breadcrumbs'
1414
import { ArticleCardItems } from 'src/landings/types'
1515

1616
export const CategoryLanding = () => {
17+
const { t } = useTranslation('cookbook_landing')
1718
const router = useRouter()
1819
const { title, intro, tocItems } = useCategoryLandingContext()
1920

@@ -84,7 +85,7 @@ export const CategoryLanding = () => {
8485
<ArticleTitle>{title}</ArticleTitle>
8586
{intro && <Lead data-search="lead">{intro}</Lead>}
8687

87-
<h2 className="py-5">Spotlight</h2>
88+
<h2 className="py-5">{t('spotlight')}</h2>
8889
<div className="d-md-flex d-sm-block col-md-12">
8990
<div className="col-md-4">
9091
<CookBookArticleCard
@@ -121,7 +122,9 @@ export const CategoryLanding = () => {
121122
<div className="pt-8">
122123
<div className="py-5 border-bottom">
123124
<div className="pb-3 mr-5 ml-1 float-xl-left">
124-
<h2>Explore {searchResults.length} prompt articles</h2>
125+
<h2>
126+
{t('explore_articles').replace('{{ number }}', searchResults.length.toString())}
127+
</h2>
125128
</div>
126129
<div>
127130
<CookBookFilter

src/landings/components/CookBookFilter.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { TextInput, ActionMenu, ActionList, Button, Box } from '@primer/react'
22
import { SearchIcon } from '@primer/octicons-react'
33
import { useRef, useEffect, useState } from 'react'
44
import { ArticleCardItems } from '#src/landings/types.ts'
5+
import { useTranslation } from 'src/languages/components/useTranslation'
56

67
type Props = {
78
tokens: ArticleCardItems
@@ -23,6 +24,7 @@ export const CookBookFilter = ({
2324
'All',
2425
...new Set(tokens.flatMap((item) => item.complexity || [])),
2526
]
27+
const { t } = useTranslation('cookbook_landing')
2628

2729
const [selectedCategory, setSelectedCategory] = useState(0)
2830
const [selectedComplexity, setSelectedComplexity] = useState(0)
@@ -61,7 +63,7 @@ export const CookBookFilter = ({
6163
leadingVisual={SearchIcon}
6264
className="m-1"
6365
sx={{ minWidth: ['stretch', 'stretch', 'stretch', 'stretch'] }}
64-
placeholder="Search articles"
66+
placeholder={t('search_articles')}
6567
ref={inputRef}
6668
autoComplete="false"
6769
onChange={(e) => {
@@ -80,7 +82,7 @@ export const CookBookFilter = ({
8082
display: 'inline-block',
8183
}}
8284
>
83-
Category:
85+
{t('category')}:
8486
</Box>{' '}
8587
{categories[selectedCategory]}
8688
</ActionMenu.Button>
@@ -107,7 +109,7 @@ export const CookBookFilter = ({
107109
display: 'inline-block',
108110
}}
109111
>
110-
Complexity:
112+
{t('complexity')}:
111113
</Box>{' '}
112114
{complexities[selectedComplexity]}
113115
</ActionMenu.Button>
@@ -127,7 +129,7 @@ export const CookBookFilter = ({
127129
</ActionMenu>
128130

129131
<Button variant="invisible" className="col-md-1 col-sm-2 mt-1" onClick={onResetFilter}>
130-
Reset filters
132+
{t('reset_filters')}
131133
</Button>
132134
</div>
133135
</div>

0 commit comments

Comments
 (0)