From 68cc216b60c30ddfa5a0a142f03a762d41c18d85 Mon Sep 17 00:00:00 2001 From: Ashley Date: Fri, 14 Feb 2025 09:49:43 -0500 Subject: [PATCH] copilot cookbook: use template strings for ui elements (#53491) Co-authored-by: Kevin Heis --- data/ui.yml | 7 +++++++ src/fixtures/fixtures/data/ui.yml | 7 +++++++ src/frame/components/context/MainContext.tsx | 1 + src/landings/components/CategoryLanding.tsx | 9 ++++++--- src/landings/components/CookBookFilter.tsx | 10 ++++++---- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/data/ui.yml b/data/ui.yml index 2ef3202ecdbd..634b9e1e9177 100644 --- a/data/ui.yml +++ b/data/ui.yml @@ -311,3 +311,10 @@ domain_edit: snippet_about: Updating will include the new domain name in all code snippets across GitHub Docs. learn_more: Learn more submission_failed: Submission failed. Please try again in a minute. +cookbook_landing: + spotlight: Spotlight + explore_articles: Explore {{ number }} prompt articles + reset_filters: Reset filters + search_articles: Search articles + category: Category + complexity: Complexity diff --git a/src/fixtures/fixtures/data/ui.yml b/src/fixtures/fixtures/data/ui.yml index 2ef3202ecdbd..634b9e1e9177 100644 --- a/src/fixtures/fixtures/data/ui.yml +++ b/src/fixtures/fixtures/data/ui.yml @@ -311,3 +311,10 @@ domain_edit: snippet_about: Updating will include the new domain name in all code snippets across GitHub Docs. learn_more: Learn more submission_failed: Submission failed. Please try again in a minute. +cookbook_landing: + spotlight: Spotlight + explore_articles: Explore {{ number }} prompt articles + reset_filters: Reset filters + search_articles: Search articles + category: Category + complexity: Complexity diff --git a/src/frame/components/context/MainContext.tsx b/src/frame/components/context/MainContext.tsx index 159703d82ead..804564f7ac0d 100644 --- a/src/frame/components/context/MainContext.tsx +++ b/src/frame/components/context/MainContext.tsx @@ -150,6 +150,7 @@ const DEFAULT_UI_NAMESPACES = [ 'support', 'rest', 'domain_edit', + 'cookbook_landing', ] export function addUINamespaces(req: any, ui: UIStrings, namespaces: string[]) { diff --git a/src/landings/components/CategoryLanding.tsx b/src/landings/components/CategoryLanding.tsx index b6d06b1a0b59..c32e73178756 100644 --- a/src/landings/components/CategoryLanding.tsx +++ b/src/landings/components/CategoryLanding.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import cx from 'classnames' import { CookBookArticleCard } from './CookBookArticleCard' import { CookBookFilter } from './CookBookFilter' - +import { useTranslation } from 'src/languages/components/useTranslation' import { DefaultLayout } from 'src/frame/components/DefaultLayout' import { ArticleTitle } from 'src/frame/components/article/ArticleTitle' import { Lead } from 'src/frame/components/ui/Lead' @@ -14,6 +14,7 @@ import { Breadcrumbs } from 'src/frame/components/page-header/Breadcrumbs' import { ArticleCardItems } from 'src/landings/types' export const CategoryLanding = () => { + const { t } = useTranslation('cookbook_landing') const router = useRouter() const { title, intro, tocItems } = useCategoryLandingContext() @@ -84,7 +85,7 @@ export const CategoryLanding = () => { {title} {intro && {intro}} -

Spotlight

+

{t('spotlight')}

{
-

Explore {searchResults.length} prompt articles

+

+ {t('explore_articles').replace('{{ number }}', searchResults.length.toString())} +

item.complexity || [])), ] + const { t } = useTranslation('cookbook_landing') const [selectedCategory, setSelectedCategory] = useState(0) const [selectedComplexity, setSelectedComplexity] = useState(0) @@ -61,7 +63,7 @@ export const CookBookFilter = ({ leadingVisual={SearchIcon} className="m-1" sx={{ minWidth: ['stretch', 'stretch', 'stretch', 'stretch'] }} - placeholder="Search articles" + placeholder={t('search_articles')} ref={inputRef} autoComplete="false" onChange={(e) => { @@ -80,7 +82,7 @@ export const CookBookFilter = ({ display: 'inline-block', }} > - Category: + {t('category')}: {' '} {categories[selectedCategory]} @@ -107,7 +109,7 @@ export const CookBookFilter = ({ display: 'inline-block', }} > - Complexity: + {t('complexity')}: {' '} {complexities[selectedComplexity]} @@ -127,7 +129,7 @@ export const CookBookFilter = ({