Translate standard page layouts (#19890)
## Context Standard page layout tabs, page layout widgets, and view field group titles were hardcoded English in the backend. This PR brings them under the same translation pipeline as views. Notes: Once a standard widget/tab/section title is overriden, the backend returns its value without translation
This commit is contained in:
@@ -32,8 +32,6 @@ import { PAGE_LAYOUT_TAB_LIST_DROPPABLE_IDS } from '@/page-layout/components/Pag
|
||||
import { PageLayoutTabListNewTabDropdownContent } from '@/page-layout/components/PageLayoutTabListNewTabDropdownContent';
|
||||
import { PageLayoutTabListReorderableOverflowDropdown } from '@/page-layout/components/PageLayoutTabListReorderableOverflowDropdown';
|
||||
import { PageLayoutTabListVisibleTabs } from '@/page-layout/components/PageLayoutTabListVisibleTabs';
|
||||
import { STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS } from '@/page-layout/constants/StandardPageLayoutTabTitleTranslations';
|
||||
import { useIsCurrentObjectCustom } from '@/page-layout/hooks/useIsCurrentObjectCustom';
|
||||
import { useIsPageLayoutInEditMode } from '@/page-layout/hooks/useIsPageLayoutInEditMode';
|
||||
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
|
||||
import { pageLayoutTabListCurrentDragDroppableIdComponentState } from '@/page-layout/states/pageLayoutTabListCurrentDragDroppableIdComponentState';
|
||||
@@ -113,9 +111,6 @@ export const PageLayoutTabList = ({
|
||||
}: PageLayoutTabListProps) => {
|
||||
const { getIcon } = useIcons();
|
||||
const { t } = useLingui();
|
||||
const { isCustom } = useIsCurrentObjectCustom();
|
||||
|
||||
const shouldTranslateTabTitles = !isCustom;
|
||||
|
||||
const isRecordPageGlobalEditionEnabled = useIsFeatureEnabled(
|
||||
FeatureFlagKey.IS_RECORD_PAGE_LAYOUT_GLOBAL_EDITION_ENABLED,
|
||||
@@ -123,12 +118,7 @@ export const PageLayoutTabList = ({
|
||||
|
||||
const tabsWithIcons: SingleTabProps[] = tabs.map((tab) => ({
|
||||
id: tab.id,
|
||||
// TODO: drop once the configuration of all record page layouts has been migrated to the backend.
|
||||
title:
|
||||
shouldTranslateTabTitles &&
|
||||
isDefined(STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS[tab.title])
|
||||
? t(STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS[tab.title])
|
||||
: tab.title,
|
||||
title: tab.title,
|
||||
Icon: isDefined(tab.icon) ? getIcon(tab.icon) : undefined,
|
||||
}));
|
||||
|
||||
|
||||
+1
-16
@@ -1,6 +1,4 @@
|
||||
import { STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS } from '@/page-layout/constants/StandardPageLayoutTabTitleTranslations';
|
||||
import { useCurrentPageLayoutOrThrow } from '@/page-layout/hooks/useCurrentPageLayoutOrThrow';
|
||||
import { useIsCurrentObjectCustom } from '@/page-layout/hooks/useIsCurrentObjectCustom';
|
||||
import { useUpdatePageLayoutTab } from '@/page-layout/hooks/useUpdatePageLayoutTab';
|
||||
import { pageLayoutTabSettingsOpenTabIdComponentState } from '@/page-layout/states/pageLayoutTabSettingsOpenTabIdComponentState';
|
||||
import { isReactivatableTab } from '@/page-layout/utils/isReactivatableTab';
|
||||
@@ -33,9 +31,6 @@ export const PageLayoutTabListNewTabDropdownContent = ({
|
||||
const { t } = useLingui();
|
||||
const { getIcon } = useIcons();
|
||||
const { closeDropdown } = useCloseDropdown();
|
||||
const { isCustom } = useIsCurrentObjectCustom();
|
||||
|
||||
const shouldTranslateTabTitles = !isCustom;
|
||||
|
||||
const { currentPageLayout } = useCurrentPageLayoutOrThrow();
|
||||
const { updatePageLayoutTab } = useUpdatePageLayoutTab();
|
||||
@@ -77,16 +72,6 @@ export const PageLayoutTabListNewTabDropdownContent = ({
|
||||
],
|
||||
);
|
||||
|
||||
const getTabTitle = (title: string) => {
|
||||
if (
|
||||
shouldTranslateTabTitles &&
|
||||
isDefined(STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS[title])
|
||||
) {
|
||||
return t(STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS[title]);
|
||||
}
|
||||
return title;
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownContent>
|
||||
<DropdownMenuHeader>{t`New tab`}</DropdownMenuHeader>
|
||||
@@ -106,7 +91,7 @@ export const PageLayoutTabListNewTabDropdownContent = ({
|
||||
<MenuItem
|
||||
key={tab.id}
|
||||
LeftIcon={isDefined(tab.icon) ? getIcon(tab.icon) : undefined}
|
||||
text={getTabTitle(tab.title)}
|
||||
text={tab.title}
|
||||
onClick={() => handleReactivateTab(tab.id)}
|
||||
/>
|
||||
))}
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
import { msg, type MacroMessageDescriptor } from '@lingui/core/macro';
|
||||
|
||||
// Translation map for standard page layout tab titles.
|
||||
// When the backend hasn't translated the tab title (e.g. when using
|
||||
// frontend fallback layouts), this map is used to translate known
|
||||
// standard tab titles at the rendering point.
|
||||
// Custom/user-created tab titles that are not in this map will be
|
||||
// displayed as-is.
|
||||
export const STANDARD_PAGE_LAYOUT_TAB_TITLE_TRANSLATIONS: Record<
|
||||
string,
|
||||
MacroMessageDescriptor
|
||||
> = {
|
||||
Home: msg`Home`,
|
||||
Timeline: msg`Timeline`,
|
||||
Tasks: msg`Tasks`,
|
||||
Notes: msg`Notes`,
|
||||
Files: msg`Files`,
|
||||
Emails: msg`Emails`,
|
||||
Calendar: msg`Calendar`,
|
||||
Note: msg`Note`,
|
||||
Flow: msg`Flow`,
|
||||
};
|
||||
Reference in New Issue
Block a user