Skip to content

Commit

Permalink
Merge pull request #55380 from drminh2807/fix/55246
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Jan 17, 2025
2 parents 987611a + 23a4306 commit d50b5ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/OptionListContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
reports: [],
personalDetails: [],
});
const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);

const personalDetails = usePersonalDetails();
Expand All @@ -71,7 +72,7 @@ function OptionsListContextProvider({children}: OptionsListProviderProps) {
return newOptions;
});
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [reports]);
}, [reports, preferredLocale]);

/**
* This effect is used to update the options list when personal details change.
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,4 +1037,15 @@ describe('OptionsListUtils', () => {
expect(canCreate).toBe(false);
});
});

it('createOptionList() localization', () => {
const reports = OptionsListUtils.createOptionList(PERSONAL_DETAILS, REPORTS).reports;
expect(reports.at(9)?.subtitle).toBe('Workspace');
return waitForBatchedUpdates()
.then(() => Onyx.set(ONYXKEYS.NVP_PREFERRED_LOCALE, CONST.LOCALES.ES))
.then(() => {
const newReports = OptionsListUtils.createOptionList(PERSONAL_DETAILS, REPORTS).reports;
expect(newReports.at(9)?.subtitle).toBe('Espacio de trabajo');
});
});
});

0 comments on commit d50b5ae

Please sign in to comment.