Skip to content

Commit dda173b

Browse files
4manasamanasa
andauthored
updates to Localization fixes (#533)
Co-authored-by: manasa <[email protected]>
1 parent 3486306 commit dda173b

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default function Assignment(props: PropsWithChildren<AssignmentProps>) {
3333

3434
const actionsAPI = thePConn.getActionsApi();
3535
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
36+
const localizationService = thePConn.getLocalizationService();
3637
const localeCategory = 'Assignment';
37-
const localeReference = getPConnect()?.getCaseLocaleReference();
3838

3939
// store off bound functions to above pointers
4040
const finishAssignment = actionsAPI.finishAssignment.bind(actionsAPI);
@@ -76,7 +76,7 @@ export default function Assignment(props: PropsWithChildren<AssignmentProps>) {
7676
function getStepsInfo(steps, formedSteps: any = []) {
7777
steps.forEach(step => {
7878
if (step.name) {
79-
step.name = PCore.getLocaleUtils().getLocaleValue(step.name, undefined, localeReference);
79+
step.name = localizationService.getLocalizedText(step.name);
8080
}
8181
if (step.steps) {
8282
formedSteps = getStepsInfo(step.steps, formedSteps);

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,19 @@ export default function NavBar(props: NavBarProps) {
133133
const portalLogoImage = Utils.getIconPath(Utils.getSDKStaticConentUrl()).concat('pzpega-logo-mark.svg');
134134
const portalOperator = PCore.getEnvironmentInfo().getOperatorName();
135135
const portalApp = PCore.getEnvironmentInfo().getApplicationLabel();
136-
136+
// @ts-ignore
137+
const localeReference = PCore.getLocaleUtils().getPortalLocaleReference() || pConn.getValue('.pyLocaleReference');
137138
useEffect(() => {
138-
setNavPages(JSON.parse(JSON.stringify(pages)));
139+
const updatedPages = pages.map((page: any) => {
140+
const destinationObject: any = {};
141+
pConn.resolveConfigProps(
142+
{ defaultHeading: page.pyDefaultHeading || page.pyLabel, localeReference: page.pyLocalizationReference },
143+
destinationObject
144+
);
145+
const name = localeUtils.getLocaleValue(destinationObject.defaultHeading, '', destinationObject.localeReference || localeReference);
146+
return { ...page, name };
147+
});
148+
setNavPages(updatedPages);
139149
}, [pages]);
140150

141151
function navPanelButtonClick(oPageData: any) {
@@ -249,7 +259,7 @@ export default function NavBar(props: NavBarProps) {
249259
{navPages.map(page => (
250260
<ListItemButton onClick={() => navPanelButtonClick(page)} key={page.pyLabel}>
251261
<ListItemIcon>{iconMap[page.pxPageViewIcon]}</ListItemIcon>
252-
<ListItemText primary={localeUtils.getLocaleValue(page.pyLabel, '', localeUtils.getCaseLocaleReference(page.pyClassName))} />
262+
<ListItemText primary={page.name} />
253263
</ListItemButton>
254264
))}
255265
</List>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@ export default function Stages(props: StagesProps) {
5757

5858
const { getPConnect, stages } = props;
5959
const pConn = getPConnect();
60-
const key = getPConnect()?.getCaseLocaleReference();
61-
60+
const localizationService = pConn.getLocalizationService();
6261
const filteredStages = getFilteredStages(stages);
6362
const currentStageID = pConn.getValue(PCore.getConstants().CASE_INFO.STAGEID, ''); // 2nd arg empty string until typedef allows optional
6463
const stagesObj = filteredStages.map((stage, index, arr) => {
6564
const theID = stage.ID || stage.id;
6665
return {
67-
name: PCore.getLocaleUtils().getLocaleValue(stage.name, undefined, key),
66+
name: localizationService.getLocalizedText(stage.name),
6867
id: theID,
6968
complete: stage.visited_status === 'completed',
7069
current: theID === currentStageID,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
7070
const editAction = availableActions.find(action => action.ID === 'pyUpdateCaseDetails');
7171

7272
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
73+
const localizationService = thePConn.getLocalizationService();
7374
const localeCategory = 'CaseView';
74-
const localeKey = thePConn?.getCaseLocaleReference();
75+
7576
/**
7677
*
7778
* @param inName the metadata <em>name</em> that will cause a region to be returned
@@ -214,7 +215,7 @@ export default function CaseView(props: PropsWithChildren<CaseViewProps>) {
214215
className={classes.caseViewHeader}
215216
title={
216217
<Typography variant='h6' component='div' id='case-name'>
217-
{PCore.getLocaleUtils().getLocaleValue(header, '', localeKey)}
218+
{localizationService.getLocalizedText(header)}
218219
</Typography>
219220
}
220221
subheader={

0 commit comments

Comments
 (0)