@redocly/theme 0.25.1 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/components/Catalog/Catalog.js +1 -4
  2. package/lib/components/CopyButton/CopyButton.js +2 -7
  3. package/lib/components/EditPageButton/EditPageButton.js +1 -4
  4. package/lib/components/Feedback/Comment.js +4 -10
  5. package/lib/components/Feedback/Mood.js +6 -13
  6. package/lib/components/Feedback/Rating.js +2 -6
  7. package/lib/components/Feedback/Reasons.js +4 -9
  8. package/lib/components/Feedback/Sentiment.js +4 -10
  9. package/lib/components/Feedback/Thumbs.js +2 -8
  10. package/lib/components/Feedback/useReportDialog.js +3 -8
  11. package/lib/components/Filter/Filter.js +1 -5
  12. package/lib/components/Filter/FilterContent.js +2 -6
  13. package/lib/components/Filter/FilterPopover.js +2 -6
  14. package/lib/components/Footer/FooterCopyright.js +2 -5
  15. package/lib/components/LastUpdated/LastUpdated.js +1 -1
  16. package/lib/components/Menu/hooks/use-mobile-menu-items.js +1 -4
  17. package/lib/components/Menu/hooks/use-mobile-menu-levels.js +2 -6
  18. package/lib/components/Menu/utils.d.ts +2 -1
  19. package/lib/components/Profile/LoginLink.js +2 -5
  20. package/lib/components/Profile/MobileUserProfile.js +1 -4
  21. package/lib/components/Profile/UserProfile.js +3 -7
  22. package/lib/components/Search/CancelSearch.js +1 -4
  23. package/lib/components/Search/RecentSearches.js +1 -4
  24. package/lib/components/Search/SearchDialog.js +4 -10
  25. package/lib/components/Search/SearchTrigger.js +1 -4
  26. package/lib/components/Search/SuggestedPages.js +1 -4
  27. package/lib/components/Sidebar/DrilldownMenu.js +2 -5
  28. package/lib/components/Sidebar/VersionPicker.js +2 -6
  29. package/lib/components/TableOfContent/TableOfContent.js +1 -4
  30. package/lib/layouts/Forbidden.js +2 -6
  31. package/lib/layouts/NotFound.js +2 -6
  32. package/lib/layouts/OIDCForbidden.js +1 -4
  33. package/lib/mocks/hooks/index.d.ts +3 -2
  34. package/lib/mocks/hooks/index.js +3 -4
  35. package/package.json +2 -2
  36. package/src/components/Catalog/Catalog.tsx +1 -4
  37. package/src/components/CopyButton/CopyButton.tsx +3 -8
  38. package/src/components/EditPageButton/EditPageButton.tsx +2 -5
  39. package/src/components/Feedback/Comment.tsx +14 -14
  40. package/src/components/Feedback/Mood.tsx +14 -15
  41. package/src/components/Feedback/Rating.tsx +4 -8
  42. package/src/components/Feedback/Reasons.tsx +6 -11
  43. package/src/components/Feedback/Sentiment.tsx +6 -12
  44. package/src/components/Feedback/Thumbs.tsx +2 -9
  45. package/src/components/Feedback/useReportDialog.ts +3 -8
  46. package/src/components/Filter/Filter.tsx +3 -5
  47. package/src/components/Filter/FilterContent.tsx +2 -6
  48. package/src/components/Filter/FilterPopover.tsx +2 -6
  49. package/src/components/Footer/FooterCopyright.tsx +2 -5
  50. package/src/components/LastUpdated/LastUpdated.tsx +1 -1
  51. package/src/components/Menu/hooks/use-mobile-menu-items.ts +1 -5
  52. package/src/components/Menu/hooks/use-mobile-menu-levels.ts +2 -7
  53. package/src/components/Menu/utils.ts +2 -1
  54. package/src/components/Profile/LoginLink.tsx +2 -5
  55. package/src/components/Profile/MobileUserProfile.tsx +1 -4
  56. package/src/components/Profile/UserProfile.tsx +5 -8
  57. package/src/components/Search/CancelSearch.tsx +2 -5
  58. package/src/components/Search/RecentSearches.tsx +2 -5
  59. package/src/components/Search/SearchDialog.tsx +8 -15
  60. package/src/components/Search/SearchTrigger.tsx +3 -5
  61. package/src/components/Search/SuggestedPages.tsx +2 -6
  62. package/src/components/Sidebar/DrilldownMenu.tsx +2 -5
  63. package/src/components/Sidebar/VersionPicker.tsx +3 -7
  64. package/src/components/TableOfContent/TableOfContent.tsx +2 -5
  65. package/src/layouts/Forbidden.tsx +4 -13
  66. package/src/layouts/NotFound.tsx +4 -13
  67. package/src/layouts/OIDCForbidden.tsx +2 -6
  68. package/src/mocks/hooks/index.ts +7 -6
@@ -34,10 +34,6 @@ export function FilterPopover({
34
34
  })
35
35
  .filter(Boolean) as ResolvedFilter[];
36
36
 
37
- const translationKeys = {
38
- placeholder: 'theme.catalog.filters.placeholder',
39
- done: 'theme.catalog.filters.done',
40
- };
41
37
  const { translate } = useTranslate();
42
38
 
43
39
  return (
@@ -45,7 +41,7 @@ export function FilterPopover({
45
41
  <FilterPopoverHeader>
46
42
  <FilterPopoverHeaderLabel>Add Filter</FilterPopoverHeaderLabel>
47
43
  <FilterPopoverHeaderButton onClick={() => setIsAddingFilter(false)}>
48
- {translate(translationKeys.placeholder, 'Done')}
44
+ {translate('theme.catalog.filters.done', 'Done')}
49
45
  </FilterPopoverHeaderButton>
50
46
  </FilterPopoverHeader>
51
47
  <FilterContent
@@ -57,7 +53,7 @@ export function FilterPopover({
57
53
  />
58
54
  <FilterControls>
59
55
  <StyledInput
60
- placeholder={translate(translationKeys.placeholder, 'Type to filter...')}
56
+ placeholder={translate('theme.catalog.filters.placeholder', 'Type to filter...')}
61
57
  value={filterTerm}
62
58
  onChange={(e) => setFilterTerm(e.target.value)}
63
59
  />
@@ -16,16 +16,13 @@ export function FooterCopyright({
16
16
  const { translate } = useTranslate();
17
17
  const { changeLanguage } = useI18n();
18
18
 
19
- const translationKeys = {
20
- copyrightText: 'theme.footer.copyrightText',
21
- };
22
19
  return copyrightText ? (
23
20
  <Wrapper
24
21
  className={className}
25
22
  data-component-name="Footer/FooterCopyright"
26
- data-translation-key={translationKeys.copyrightText}
23
+ data-translation-key="theme.footer.copyrightText"
27
24
  >
28
- <Label>{translate(translationKeys.copyrightText, copyrightText)}</Label>
25
+ <Label>{translate('theme.footer.copyrightText', copyrightText)}</Label>
29
26
  <LanguagePicker onChangeLanguage={changeLanguage} placement="top" alignment="end" />
30
27
  </Wrapper>
31
28
  ) : null;
@@ -40,7 +40,7 @@ export function LastUpdated(props: LastUpdatedProps): JSX.Element | null {
40
40
 
41
41
  const text =
42
42
  format === 'timeago'
43
- ? translate(translationKey, 'Last updated ')
43
+ ? translate(translationKey, 'Last updated') + ' '
44
44
  : translate(translationKey, 'Last updated on');
45
45
 
46
46
  return (
@@ -13,10 +13,6 @@ const MENU_SEPARATOR: ResolvedNavItem = {
13
13
  separatorLine: true,
14
14
  };
15
15
 
16
- const TRANSLATION_KEYS = {
17
- products: 'theme.mobileMenu.products',
18
- };
19
-
20
16
  export const useMobileMenuItems = (menuType: MenuType) => {
21
17
  const { versions = [] } = usePageVersions() || {};
22
18
  const { defaultLocale, currentLocale, locales } = useI18nConfig();
@@ -71,7 +67,7 @@ export const useMobileMenuItems = (menuType: MenuType) => {
71
67
  if (productMenuItems.length) {
72
68
  menuItems.push({
73
69
  type: 'separator',
74
- label: translate(TRANSLATION_KEYS.products, 'Products'),
70
+ label: translate('theme.mobileMenu.products', 'Products'),
75
71
  });
76
72
 
77
73
  menuItems.push(...productMenuItems);
@@ -7,11 +7,6 @@ import { MenuType } from '@theme/components/Menu/constants';
7
7
  import { useThemeConfig } from '@theme/hooks';
8
8
  import type { ResolvedNavItem } from '@theme/types/portal';
9
9
 
10
- const TRANSLATION_KEYS = {
11
- mainMenu: 'theme.mobileMenu.mainMenu',
12
- previous: 'theme.mobileMenu.previous',
13
- };
14
-
15
10
  export const useMobileMenuLevels = () => {
16
11
  const { versions = [] } = usePageVersions() || {};
17
12
  const activeVersion = versions.find((version) => version?.active);
@@ -29,7 +24,7 @@ export const useMobileMenuLevels = () => {
29
24
  const menuLevels = useMemo(() => {
30
25
  const menuLevels = [
31
26
  {
32
- label: translate(TRANSLATION_KEYS.mainMenu, 'Main Menu'),
27
+ label: translate('theme.mobileMenu.mainMenu', 'Main Menu'),
33
28
  type: MenuType.MAIN_MENU,
34
29
  },
35
30
  ];
@@ -43,7 +38,7 @@ export const useMobileMenuLevels = () => {
43
38
 
44
39
  if (sidebarItems.length || activeVersion) {
45
40
  menuLevels.push({
46
- label: translate(TRANSLATION_KEYS.previous, 'Previous'),
41
+ label: translate('theme.mobileMenu.previous', 'Previous'),
47
42
  type: MenuType.PAGE,
48
43
  });
49
44
  }
@@ -1,7 +1,8 @@
1
1
  import type { Location } from 'react-router-dom';
2
+ import type { TFunction } from '@redocly/portal-types';
2
3
 
3
4
  import type { ItemState } from '@theme/components/Sidebar/types';
4
- import type { Locale, ResolvedNavItem, TFunction, Version } from '@theme/types/portal';
5
+ import type { Locale, ResolvedNavItem, Version } from '@theme/types/portal';
5
6
  import { getPathnameForLocale } from '@portal/utils';
6
7
  import { withPathPrefix } from '@theme/utils/urls';
7
8
 
@@ -12,19 +12,16 @@ export interface LoginLinkProps {
12
12
  export function LoginLink({ href }: LoginLinkProps): JSX.Element {
13
13
  const { userProfile } = useThemeConfig();
14
14
  const { translate } = useTranslate();
15
- const translationKeys = {
16
- login: 'theme.profile.login',
17
- };
18
15
 
19
16
  return (
20
17
  <StyledLink
21
18
  href={href}
22
- data-translation-key={translationKeys.login}
19
+ data-translation-key="theme.profile.login"
23
20
  onClick={() => {
24
21
  telemetry.send('login_button_clicked', {});
25
22
  }}
26
23
  >
27
- {translate(translationKeys.login, userProfile?.loginLabel || 'Login')}
24
+ {translate('theme.profile.login', userProfile?.loginLabel || 'Login')}
28
25
  </StyledLink>
29
26
  );
30
27
  }
@@ -12,9 +12,6 @@ export function MobileUserProfile() {
12
12
  const { userProfile } = useThemeConfig();
13
13
  const { userData, handleLogout, loginUrl } = useProfileProps();
14
14
  const { translate } = useTranslate();
15
- const translationKeys = {
16
- login: 'theme.profile.login',
17
- };
18
15
 
19
16
  if (!userData?.isAuthenticated && !loginUrl) return null;
20
17
 
@@ -26,7 +23,7 @@ export function MobileUserProfile() {
26
23
  data-cy="login-btn"
27
24
  onClick={() => telemetry.send('login_button_clicked', {})}
28
25
  >
29
- {translate(translationKeys.login, userProfile?.loginLabel || 'Login')}
26
+ {translate('theme.profile.login', userProfile?.loginLabel || 'Login')}
30
27
  </LoginButton>
31
28
  ) : (
32
29
  <>
@@ -18,18 +18,15 @@ export function UserProfile({
18
18
  }: UserProfileProps): JSX.Element {
19
19
  const { userProfile } = useThemeConfig();
20
20
  const { translate } = useTranslate();
21
- const translationKeys = {
22
- myApps: 'theme.profile.myApps',
23
- logout: 'theme.profile.logout',
24
- };
21
+
25
22
  const [isOpened, setIsOpened] = useState<boolean>(false);
26
23
 
27
24
  const menuItems: JSX.Element[] = [<UserProfileData key={userData.name} userData={userData} />];
28
25
 
29
26
  if (hasDeveloperOnboarding) {
30
27
  menuItems.push(
31
- <Link to="/apps" data-translation-key={translationKeys.myApps}>
32
- {translate(translationKeys.myApps, 'My Apps')}
28
+ <Link to="/apps" data-translation-key="theme.profile.myApps">
29
+ {translate('theme.profile.myApps', 'My Apps')}
33
30
  </Link>,
34
31
  );
35
32
  }
@@ -55,11 +52,11 @@ export function UserProfile({
55
52
  handleLogout();
56
53
  telemetry.send('logout_menu_item_clicked', {});
57
54
  }}
58
- data-translation-key={translationKeys.logout}
55
+ data-translation-key="theme.profile.logout"
59
56
  role="link"
60
57
  >
61
58
  <LogoutIcon />
62
- {translate(translationKeys.logout, userProfile?.logoutLabel || 'Log out')}
59
+ {translate('theme.profile.logout', userProfile?.logoutLabel || 'Log out')}
63
60
  </Logout>,
64
61
  );
65
62
 
@@ -12,14 +12,11 @@ export function CancelSearch({
12
12
  className?: string;
13
13
  }): JSX.Element {
14
14
  const { translate } = useTranslate();
15
- const translationKeys = {
16
- cancel: 'theme.search.cancel',
17
- };
18
15
 
19
16
  return (
20
17
  <Wrapper data-component-name="Search/CancelSearch" onClick={onClick} className={className}>
21
- <Button data-translation-keys={translationKeys.cancel} fullWidth variant="outlined">
22
- {translate(translationKeys.cancel, 'Cancel')}
18
+ <Button data-translation-keys="theme.search.cancel" fullWidth variant="outlined">
19
+ {translate('theme.search.cancel', 'Cancel')}
23
20
  </Button>
24
21
  </Wrapper>
25
22
  );
@@ -15,9 +15,6 @@ export function RecentSearches({
15
15
  }) {
16
16
  const { items, removeSearchHistoryItem } = useRecentSearches();
17
17
  const { translate } = useTranslate();
18
- const translationKeys = {
19
- title: 'theme.search.recent',
20
- };
21
18
 
22
19
  if (!items || !items.length) return null;
23
20
 
@@ -34,8 +31,8 @@ export function RecentSearches({
34
31
 
35
32
  return (
36
33
  <Wrapper data-component-name="Search/RecentSearches" className={className}>
37
- <Title data-translation-key={translationKeys.title}>
38
- {translate(translationKeys.title, 'Recent searches')}
34
+ <Title data-translation-key="theme.search.recent">
35
+ {translate('theme.search.recent', 'Recent searches')}
39
36
  </Title>
40
37
  <RecentItems>
41
38
  {items.map((item) => (
@@ -39,13 +39,6 @@ export const SearchDialog = ({
39
39
  }
40
40
  };
41
41
 
42
- const translationKeys = {
43
- noResults: 'theme.search.noResults',
44
- navigate: 'theme.search.keys.navigate',
45
- select: 'theme.search.keys.select',
46
- exit: 'theme.search.keys.exit',
47
- };
48
-
49
42
  const mapItem = (item: SearchDocument) => {
50
43
  return (
51
44
  <SearchItem key={item.id} item={item} product={!product ? item.product?.name : undefined} />
@@ -74,8 +67,8 @@ export const SearchDialog = ({
74
67
  items.length ? (
75
68
  items.map(mapItem)
76
69
  ) : (
77
- <Message data-translation-key={translationKeys.noResults}>
78
- {translate(translationKeys.noResults, 'No results')}
70
+ <Message data-translation-key="theme.search.noResults">
71
+ {translate('theme.search.noResults', 'No results')}
79
72
  </Message>
80
73
  )
81
74
  ) : (
@@ -88,19 +81,19 @@ export const SearchDialog = ({
88
81
  <BottomContainer>
89
82
  <Shortcuts>
90
83
  <Shortcut
91
- data-translation-key={translationKeys.navigate}
84
+ data-translation-key="theme.search.keys.navigate"
92
85
  combination="Tab"
93
- text={translate(translationKeys.navigate, 'to navigate')}
86
+ text={translate('theme.search.keys.navigate', 'to navigate')}
94
87
  />
95
88
  <Shortcut
96
- data-translation-key={translationKeys.select}
89
+ data-translation-key="theme.search.keys.select"
97
90
  combination="↵"
98
- text={translate(translationKeys.select, 'to select')}
91
+ text={translate('theme.search.keys.select', 'to select')}
99
92
  />
100
93
  <Shortcut
101
- data-translation-key={translationKeys.exit}
94
+ data-translation-key="theme.search.keys.exit"
102
95
  combination="Esc"
103
- text={translate(translationKeys.exit, 'to exit')}
96
+ text={translate('theme.search.keys.exit', 'to exit')}
104
97
  />
105
98
  </Shortcuts>
106
99
  <CancelSearch onClick={onClose} />
@@ -15,16 +15,14 @@ export function SearchTrigger({
15
15
  }): JSX.Element {
16
16
  const themeSettings = useThemeConfig();
17
17
  const { translate } = useTranslate();
18
- const translationKeys = {
19
- label: 'theme.search.navbar.label',
20
- };
18
+
21
19
  const keyShortcuts = themeSettings?.search?.shortcuts ?? ['/'];
22
20
 
23
21
  return (
24
22
  <Wrapper data-component-name="Search/SearchTrigger" onClick={onClick} className={className}>
25
23
  <SearchIconSmall />
26
- <Label data-translation-key={translationKeys.label}>
27
- {translate(translationKeys.label, 'Search')}
24
+ <Label data-translation-key="theme.search.navbar.label">
25
+ {translate('theme.search.navbar.label', 'Search')}
28
26
  </Label>
29
27
  <ShortcutKey keyShortcuts={keyShortcuts} />
30
28
  </Wrapper>
@@ -9,16 +9,12 @@ import { useTranslate } from '@portal/hooks';
9
9
  export function SuggestedPages({ className }: { className?: string }) {
10
10
  const pages = useSuggestedPages();
11
11
  const { translate } = useTranslate();
12
- const translationKeys = {
13
- title: 'theme.search.suggested',
14
- };
15
-
16
12
  if (!pages.length) return null;
17
13
 
18
14
  return (
19
15
  <Wrapper data-component-name="Search/SuggestedPages" className={className}>
20
- <Title data-translation-key={translationKeys.title}>
21
- {translate(translationKeys.title, 'Suggested pages')}
16
+ <Title data-translation-key="theme.search.suggested">
17
+ {translate('theme.search.suggested', 'Suggested pages')}
22
18
  </Title>
23
19
  <SuggestedItems>
24
20
  {pages.map(
@@ -15,19 +15,16 @@ export function DrilldownMenu({
15
15
  className,
16
16
  }: React.PropsWithChildren<DrilldownMenuProps>): JSX.Element {
17
17
  const { translate } = useTranslate();
18
- const translationKeys = {
19
- backLabel: 'theme.sidebar.menu.backLabel',
20
- };
21
18
  const label =
22
19
  item.label === prevActiveItem?.label || !prevActiveItem?.label
23
- ? translate(translationKeys.backLabel, 'Back')
20
+ ? translate('theme.sidebar.menu.backLabel', 'Back')
24
21
  : prevActiveItem?.label;
25
22
 
26
23
  return (
27
24
  <MenuContainer data-component-name="Sidebar/DrilldownMenu" className={className}>
28
25
  <MenuContent>
29
26
  <MenuWrapper>
30
- <BackButton back={back} data-translation-key={translationKeys.backLabel}>
27
+ <BackButton back={back} data-translation-key="theme.sidebar.menu.backLabel">
31
28
  {label}
32
29
  </BackButton>
33
30
  <MenuLinkItem item={item}>
@@ -16,10 +16,6 @@ export function VersionPicker(props: { versions?: Version[]; onChange: (v: Versi
16
16
  const { versionPicker } = themeConfig;
17
17
 
18
18
  const { translate } = useTranslate();
19
- const translationKeys = {
20
- label: 'theme.versionPicker.label',
21
- unversioned: 'theme.versionPicker.unversioned',
22
- };
23
19
 
24
20
  const { versions = [], onChange } = props;
25
21
  const options = versions.map((version) => {
@@ -40,11 +36,11 @@ export function VersionPicker(props: { versions?: Version[]; onChange: (v: Versi
40
36
 
41
37
  return (
42
38
  <VersionsPickerWrapper>
43
- <VersionPickerLabel data-translation-key={translationKeys.label}>
44
- {translate(translationKeys.label, 'Version:')}
39
+ <VersionPickerLabel data-translation-key="theme.versionPicker.label">
40
+ {translate('theme.versionPicker.label', 'Version:')}
45
41
  </VersionPickerLabel>
46
42
  <VersionPickerSelect
47
- placeholder={translate(translationKeys.unversioned, 'All versions')}
43
+ placeholder={translate('theme.versionPicker.unversioned', 'All versions')}
48
44
  disabled={!options.length}
49
45
  options={options}
50
46
  value={value}
@@ -35,9 +35,6 @@ export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
35
35
  );
36
36
 
37
37
  const { translate } = useTranslate();
38
- const translationKeys = {
39
- header: 'theme.toc.header',
40
- };
41
38
 
42
39
  if (toc?.hide) {
43
40
  return null;
@@ -48,8 +45,8 @@ export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
48
45
  <TableOfContentMenu data-component-name="TableOfContent/TableOfContent" className={className}>
49
46
  <TableOfContentItems ref={sidebar}>
50
47
  {displayedHeadings.length ? (
51
- <TocHeader data-translation-key={translationKeys.header}>
52
- {translate(translationKeys.header, toc.header || 'On this page')}
48
+ <TocHeader data-translation-key="theme.toc.header">
49
+ {translate('theme.toc.header', toc.header || 'On this page')}
53
50
  </TocHeader>
54
51
  ) : null}
55
52
  {displayedHeadings.map((heading: MdHeading | null, idx: number) => {
@@ -6,24 +6,15 @@ import { useTranslate } from '@portal/hooks';
6
6
 
7
7
  export function Forbidden(): JSX.Element {
8
8
  const { translate } = useTranslate();
9
- const translationKeys = {
10
- title: 'theme.page.forbidden.title',
11
- homeButton: 'theme.page.homeButton',
12
- };
13
9
 
14
10
  return (
15
11
  <Wrapper data-component-name="Pages/Forbidden">
16
12
  <Header>403</Header>
17
- <Description data-translation-key={translationKeys.title}>
18
- {translate(translationKeys.title, 'Access forbidden')}
13
+ <Description data-translation-key="theme.page.forbidden.title">
14
+ {translate('theme.page.forbidden.title', 'Access forbidden')}
19
15
  </Description>
20
- <HomeButton
21
- color="primary"
22
- size="large"
23
- to="/"
24
- data-translation-key={translationKeys.homeButton}
25
- >
26
- {translate(translationKeys.homeButton, 'Open Homepage')}
16
+ <HomeButton color="primary" size="large" to="/" data-translation-key="theme.page.homeButton">
17
+ {translate('theme.page.homeButton', 'Open Homepage')}
27
18
  </HomeButton>
28
19
  </Wrapper>
29
20
  );
@@ -6,24 +6,15 @@ import { useTranslate } from '@portal/hooks';
6
6
 
7
7
  export function NotFound(): JSX.Element {
8
8
  const { translate } = useTranslate();
9
- const translationKeys = {
10
- title: 'theme.page.notFound.title',
11
- homeButton: 'theme.page.homeButton',
12
- };
13
9
 
14
10
  return (
15
11
  <Wrapper data-component-name="Pages/NotFound">
16
12
  <Header>404</Header>
17
- <Description data-translation-key={translationKeys.title}>
18
- {translate(translationKeys.title, `It looks like you're lost`)}
13
+ <Description data-translation-key="theme.page.notFound.title">
14
+ {translate('theme.page.notFound.title', "It looks like you're lost")}
19
15
  </Description>
20
- <HomeButton
21
- color="primary"
22
- size="large"
23
- to="/"
24
- data-translation-key={translationKeys.homeButton}
25
- >
26
- {translate(translationKeys.homeButton, 'Open Homepage')}
16
+ <HomeButton color="primary" size="large" to="/" data-translation-key="theme.page.homeButton">
17
+ {translate('theme.page.homeButton', 'Open Homepage')}
27
18
  </HomeButton>
28
19
  </Wrapper>
29
20
  );
@@ -9,10 +9,6 @@ export function OIDCForbidden(): JSX.Element {
9
9
  const [searchParams, setSearchParams] = useSearchParams();
10
10
  const [errorDescription, setErrorDescription] = useState<string>('');
11
11
 
12
- const translationKeys = {
13
- title: 'theme.page.forbidden.title',
14
- };
15
-
16
12
  // use whatever you want here
17
13
  const URL_REGEX =
18
14
  /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;
@@ -38,8 +34,8 @@ export function OIDCForbidden(): JSX.Element {
38
34
  return (
39
35
  <Wrapper data-component-name="Pages/OIDCForbidden">
40
36
  <Header>403</Header>
41
- <Description data-translation-key={translationKeys.title}>
42
- {translate(translationKeys.title, 'Access forbidden')}
37
+ <Description data-translation-key="theme.page.forbidden.title">
38
+ {translate('theme.page.forbidden.title', 'Access forbidden')}
43
39
  </Description>
44
40
  {errorDescription && <ErrorDescription>{renderText(errorDescription)}</ErrorDescription>}
45
41
  </Wrapper>
@@ -1,5 +1,7 @@
1
+ import type { TFunction } from '@redocly/portal-types';
2
+
1
3
  import type { CatalogConfig, ProductUiConfig, ThemeUIConfig } from '@theme/config';
2
- import type { ResolvedNavItem, TFunction, Version } from '@theme/types/portal';
4
+ import type { ResolvedNavItem, Version } from '@theme/types/portal';
3
5
  import type { FilteredCatalog } from '@theme/types/portal/src/shared/types/catalog';
4
6
  interface PageLink {
5
7
  label: string;
@@ -76,11 +78,10 @@ export function useCatalog(_items: ResolvedNavItem[], _config: CatalogConfig): F
76
78
  throw new Error('Mock not implemented yet.');
77
79
  }
78
80
 
79
- export function useTranslate() {
80
- const translate: TFunction = (value?: string, options?: { defaultValue: string } | string) =>
81
- (typeof options === 'string' ? options : options?.defaultValue) || value || '';
82
- return { translate };
83
- }
81
+ export const useTranslate = (): { translate: TFunction } => ({
82
+ translate: (value?: string, options?: { defaultValue: string } | string) =>
83
+ (typeof options === 'string' ? options : options?.defaultValue) || value || '',
84
+ });
84
85
 
85
86
  export function useI18n() {
86
87
  const changeLanguage = (...args: any) => args.value as string;