Skip to content

Commit 3486306

Browse files
4manasamanasa
andauthored
Fixed the Localization issues (#532)
Co-authored-by: manasa <[email protected]>
1 parent d24bd62 commit 3486306

File tree

13 files changed

+29
-33
lines changed

13 files changed

+29
-33
lines changed

packages/react-sdk-components/src/components/field/SelectableCard/utils.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ export function resolveReferenceFields(
199199
...preset,
200200
config: {
201201
...preset.config,
202-
displayMode: 'DISPLAY_ONLY'
202+
displayMode: 'DISPLAY_ONLY',
203+
contextName: pConnect.getContextName()
203204
}
204205
},
205206
useCustomContext: item

packages/react-sdk-components/src/components/helpers/common-utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ export function isEmptyObject(obj: object): boolean {
99
* @returns The localized string or the key itself if no translation is found
1010
*/
1111
export function getGenericFieldsLocalizedValue(path: string, key: string): string {
12-
const GENERIC_BUNDLE_KEY = PCore.getLocaleUtils().GENERIC_BUNDLE_KEY;
13-
const localeStore = PCore.getLocaleUtils().localeStore[GENERIC_BUNDLE_KEY];
12+
const localeStore = PCore.getLocaleUtils().localeStore;
1413

1514
if (!localeStore) return key;
1615

packages/react-sdk-components/src/components/infra/Assignment/Assignment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function Assignment(props: PropsWithChildren<AssignmentProps>) {
3434
const actionsAPI = thePConn.getActionsApi();
3535
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
3636
const localeCategory = 'Assignment';
37-
const localeReference = `${getPConnect().getCaseInfo().getClassName()}!CASE!${getPConnect().getCaseInfo().getName()}`.toUpperCase();
37+
const localeReference = getPConnect()?.getCaseLocaleReference();
3838

3939
// store off bound functions to above pointers
4040
const finishAssignment = actionsAPI.finishAssignment.bind(actionsAPI);

packages/react-sdk-components/src/components/infra/Containers/FlowContainer/FlowContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const FlowContainer = (props: FlowContainerProps) => {
9696
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
9797
const localeCategory = 'Messages';
9898

99-
const key = `${thePConn.getCaseInfo().getClassName()}!CASE!${thePConn.getCaseInfo().getName()}`.toUpperCase();
99+
const key = getPConnect()?.getCaseLocaleReference();
100100
const classes = useStyles();
101101

102102
function getBuildName(): string {
@@ -218,7 +218,7 @@ export const FlowContainer = (props: FlowContainerProps) => {
218218
<CardHeader
219219
id='assignment-header'
220220
title={<Typography variant='h6'>{localizedVal(containerName, undefined, key)}</Typography>}
221-
subheader={`${localizedVal('Task in', 'Todo')} ${caseId} \u2022 ${localizedVal('Priority', 'Todo')} ${urgency}`}
221+
subheader={`${localizedVal('In', 'Todo')} ${caseId} \u2022 ${localizedVal('Priority', 'Todo')} ${urgency}`}
222222
avatar={<Avatar className={`${classes.avatar} psdk-avatar`}>{operatorInitials}</Avatar>}
223223
/>
224224
{displayPageMessages()}

packages/react-sdk-components/src/components/infra/Containers/ModalViewContainer/ModalViewContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export default function ModalViewContainer(props: ModalViewContainerProps) {
131131
const [cancelAlertProps, setCancelAlertProps] = useState({});
132132
const [isMultiRecordData, setMultiRecordData] = useState(false);
133133
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
134-
const localeCategory = 'Data Object';
134+
const localeCategory = 'ModalContainer';
135135

136136
const ERROR_WHILE_RENDERING = 'ERROR_WHILE_RENDERING';
137137

@@ -255,7 +255,7 @@ export default function ModalViewContainer(props: ModalViewContainerProps) {
255255
const headingValue =
256256
isDataObject || isMultiRecord
257257
? getModalHeading(dataObjectAction)
258-
: determineModalHeaderByAction(actionName, caseTypeName, ID, `${caseInfo?.getClassName()}!CASE!${caseInfo.getName()}`.toUpperCase());
258+
: determineModalHeaderByAction(actionName, caseTypeName, ID, pConnect?.getCaseLocaleReference());
259259

260260
let arChildrenAsReact: any[] = [];
261261

packages/react-sdk-components/src/components/infra/NavBar/NavBar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ export default function NavBar(props: NavBarProps) {
126126
const [bShowOperatorButtons, setBShowOperatorButtons] = useState(false);
127127
const [anchorEl, setAnchorEl] = useState(null);
128128
const localeUtils = PCore.getLocaleUtils();
129-
const localeReference = pConn.getValue('.pyLocaleReference');
130129

131130
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
132131
const localeCategory = 'AppShell';
@@ -241,7 +240,7 @@ export default function NavBar(props: NavBarProps) {
241240
<ListItemIcon>
242241
<WorkOutlineIcon fontSize='large' />
243242
</ListItemIcon>
244-
<ListItemText primary={localeUtils.getLocaleValue(caseType.pyLabel, '', localeReference)} />
243+
<ListItemText primary={localeUtils.getLocaleValue(caseType.pyLabel, '', localeUtils.getCaseLocaleReference(caseType.pyClassName))} />
245244
</ListItemButton>
246245
))}
247246
</List>
@@ -250,7 +249,7 @@ export default function NavBar(props: NavBarProps) {
250249
{navPages.map(page => (
251250
<ListItemButton onClick={() => navPanelButtonClick(page)} key={page.pyLabel}>
252251
<ListItemIcon>{iconMap[page.pxPageViewIcon]}</ListItemIcon>
253-
<ListItemText primary={localeUtils.getLocaleValue(page.pyLabel, '', localeReference)} />
252+
<ListItemText primary={localeUtils.getLocaleValue(page.pyLabel, '', localeUtils.getCaseLocaleReference(page.pyClassName))} />
254253
</ListItemButton>
255254
))}
256255
</List>

packages/react-sdk-components/src/components/infra/Stages/Stages.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function Stages(props: StagesProps) {
5757

5858
const { getPConnect, stages } = props;
5959
const pConn = getPConnect();
60-
const key = `${pConn.getCaseInfo().getClassName()}!CASE!${pConn.getCaseInfo().getName()}`.toUpperCase();
60+
const key = getPConnect()?.getCaseLocaleReference();
6161

6262
const filteredStages = getFilteredStages(stages);
6363
const currentStageID = pConn.getValue(PCore.getConstants().CASE_INFO.STAGEID, ''); // 2nd arg empty string until typedef allows optional

packages/react-sdk-components/src/components/template/CaseView/CaseView.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Utils } from '../../helpers/utils';
99
import StoreContext from '../../../bridge/Context/StoreContext';
1010
import { getComponentFromMap } from '../../../bridge/helpers/sdk_component_map';
1111
import type { PConnProps } from '../../../types/PConnProps';
12-
import { prepareCaseSummaryData } from '../utils';
1312

1413
interface CaseViewProps extends PConnProps {
1514
// If any, enter additional props that only exist on this component
@@ -50,7 +49,6 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
5049
const CaseViewActionsMenu = getComponentFromMap('CaseViewActionsMenu');
5150
const VerticalTabs = getComponentFromMap('VerticalTabs');
5251
const DeferLoad = getComponentFromMap('DeferLoad');
53-
const CaseSummary = getComponentFromMap('CaseSummary');
5452

5553
const {
5654
getPConnect,
@@ -73,7 +71,7 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
7371

7472
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
7573
const localeCategory = 'CaseView';
76-
const localeKey = `${caseTypeID}!CASE!${caseTypeName}`.toUpperCase();
74+
const localeKey = thePConn?.getCaseLocaleReference();
7775
/**
7876
*
7977
* @param inName the metadata <em>name</em> that will cause a region to be returned
@@ -90,12 +88,7 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
9088
return null;
9189
}
9290

93-
const theSummaryRegion = children && children[0];
94-
95-
const data = prepareCaseSummaryData(theSummaryRegion);
96-
const primarySummaryFields = data.primarySummaryFields;
97-
const secondarySummaryFields = data.secondarySummaryFields;
98-
91+
const theSummaryRegion = getChildRegionByName('summary');
9992
const theStagesRegion = getChildRegionByName('stages');
10093
const theTodoRegion = getChildRegionByName('todo');
10194
const theUtilitiesRegion = getChildRegionByName('utilities');
@@ -237,7 +230,7 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
237230
/>
238231
{getActionButtonsHtml()}
239232
<Divider />
240-
<CaseSummary arPrimaryFields={primarySummaryFields} arSecondaryFields={secondarySummaryFields}></CaseSummary>
233+
{theSummaryRegion}
241234
<Divider />
242235
{vertTabInfo.length > 1 && <VerticalTabs tabconfig={vertTabInfo} />}
243236
</Card>

packages/react-sdk-components/src/components/template/DataReference/DataReference.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ export default function DataReference(props: PropsWithChildren<DataReferenceProp
8888
let firstChildPConnect;
8989

9090
const localizedPlaceholderOption = placeholder => {
91-
const { GENERIC_BUNDLE_KEY } = PCore.getLocaleUtils?.() ?? {};
92-
const localizedDefaultPlaceholder = pConn.getLocalizedValue('select_placeholder_default', 'CosmosFields', GENERIC_BUNDLE_KEY);
91+
const localizedDefaultPlaceholder = pConn.getLocalizedValue('select_placeholder_default', '', 'CosmosFields');
9392
// If we have a placeholder, push that option in the list of items
9493
if (placeholder === 'Select...' && localizedDefaultPlaceholder !== 'select_placeholder_default') {
9594
return localizedDefaultPlaceholder;

packages/react-sdk-components/src/components/template/ListView/ListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ export default function ListView(props: ListViewProps) {
12121212
</TableBody>
12131213
</Table>
12141214
{(!arRows || arRows.length === 0) && (
1215-
<div className='no-records'>{getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.')}</div>
1215+
<div className='no-records'>{getGenericFieldsLocalizedValue('COSMOSFIELDS.lists', 'No records found.')}</div>
12161216
)}
12171217
</TableContainer>
12181218
)}

0 commit comments

Comments
 (0)