Skip to content

Commit b486a5a

Browse files
chore(orama): translate search box (#7799)
* chore(orama): translate search box * Apply suggestions from code review Co-authored-by: Brian Muenzenmeyer <[email protected]> Signed-off-by: Aviv Keller <[email protected]> --------- Signed-off-by: Aviv Keller <[email protected]> Co-authored-by: Brian Muenzenmeyer <[email protected]>
1 parent 8e5d403 commit b486a5a

File tree

5 files changed

+137
-33
lines changed

5 files changed

+137
-33
lines changed

apps/site/components/Common/Search/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type ResultMapDescription = {
2121

2222
type ResultMapPath = { path: string; siteSection: string };
2323

24-
import { themeConfig } from './utils';
24+
import { themeConfig, translationKeys } from './utils';
2525

2626
const uppercaseFirst = (word: string) =>
2727
word.charAt(0).toUpperCase() + word.slice(1);
@@ -63,9 +63,9 @@ const SearchButton: FC = () => {
6363
style={{ flexGrow: 1 }}
6464
colorScheme={colorScheme}
6565
themeConfig={themeConfig}
66-
aria-label={t('components.search.searchBox.placeholder')}
66+
aria-label={t('components.search.searchPlaceholder')}
6767
>
68-
{t('components.search.searchBox.placeholder')}
68+
{t('components.search.searchPlaceholder')}
6969
</OramaSearchButton>
7070

7171
<OramaSearchBox
@@ -82,6 +82,9 @@ const SearchButton: FC = () => {
8282
HTMLTag: 'b',
8383
CSSClass: 'font-bold',
8484
}}
85+
dictionary={Object.fromEntries(
86+
translationKeys.map(key => [key, t(`components.search.${key}`)])
87+
)}
8588
searchParams={DEFAULT_ORAMA_QUERY_PARAMS}
8689
suggestions={DEFAULT_ORAMA_SUGGESTIONS}
8790
chatMarkdownLinkHref={({ href }) => {

apps/site/components/Common/Search/utils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,20 @@ export const themeConfig = {
4141
},
4242
},
4343
};
44+
45+
export const translationKeys = [
46+
'searchPlaceholder',
47+
'chatPlaceholder',
48+
'noResultsFoundFor',
49+
'suggestions',
50+
'seeAll',
51+
'addMore',
52+
'clearChat',
53+
'errorMessage',
54+
'disclaimer',
55+
'startYourSearch',
56+
'initErrorSearch',
57+
'initErrorChat',
58+
'chatButtonLabel',
59+
'searchButtonLabel',
60+
] as const;

apps/site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@opentelemetry/instrumentation": "~0.200.0",
3838
"@opentelemetry/resources": "~1.30.1",
3939
"@opentelemetry/sdk-logs": "~0.200.0",
40-
"@orama/react-components": "^0.7.0",
40+
"@orama/react-components": "^0.8.0",
4141
"@oramacloud/client": "^2.1.4",
4242
"@radix-ui/react-slot": "^1.1.2",
4343
"@radix-ui/react-tabs": "^1.1.3",

packages/i18n/locales/en.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,20 @@
238238
"tableOfContents": "Table of Contents"
239239
},
240240
"search": {
241-
"searchBox": {
242-
"placeholder": "Start typing..."
243-
}
241+
"searchPlaceholder": "Start typing...",
242+
"chatPlaceholder": "Ask me anything",
243+
"noResultsFoundFor": "No results found for",
244+
"suggestions": "Suggestions",
245+
"seeAll": "See all",
246+
"addMore": "Add more",
247+
"clearChat": "Clear chat",
248+
"errorMessage": "An error occurred while trying to search. Please try again.",
249+
"disclaimer": "AI summaries can make mistakes. Please verify the information.",
250+
"startYourSearch": "Start your search",
251+
"initErrorSearch": "Unable to initialize search service",
252+
"initErrorChat": "Unable to initialize chat service",
253+
"chatButtonLabel": "Get an AI summary",
254+
"searchButtonLabel": "Search"
244255
},
245256
"blog": {
246257
"blogHeader": {

pnpm-lock.yaml

Lines changed: 99 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)