Skip to content

Commit

Permalink
Merge pull request #29736 from tienifr/fix/29620
Browse files Browse the repository at this point in the history
fix: 29620 Site in Spanish automatically changes to English on signing out
  • Loading branch information
johnmlee101 committed Oct 18, 2023
2 parents 3b86da6 + 434842c commit b64fd34
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/pages/signin/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ const propTypes = {

/** Whether or not the sign in page is being rendered in the RHP modal */
isInModal: PropTypes.bool,

/** The user's preferred locale */
preferredLocale: PropTypes.string,
};

const defaultProps = {
account: {},
credentials: {},
isInModal: false,
activeClients: [],
preferredLocale: '',
};

/**
Expand Down Expand Up @@ -131,7 +135,7 @@ function getRenderOptions({hasLogin, hasValidateCode, account, isPrimaryLogin, i
};
}

function SignInPage({credentials, account, isInModal, activeClients}) {
function SignInPage({credentials, account, isInModal, activeClients, preferredLocale}) {
const {translate, formatPhoneNumber} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
const shouldShowSmallScreen = isSmallScreenWidth || isInModal;
Expand All @@ -153,8 +157,11 @@ function SignInPage({credentials, account, isInModal, activeClients}) {

useEffect(() => Performance.measureTTI(), []);
useEffect(() => {
if (preferredLocale) {
return;
}
App.setLocale(Localize.getDevicePreferredLocale());
}, []);
}, [preferredLocale]);

const {
shouldShowLoginForm,
Expand Down Expand Up @@ -273,4 +280,7 @@ export default withOnyx({
We use that function to prevent repeating code that checks which client is the leader.
*/
activeClients: {key: ONYXKEYS.ACTIVE_CLIENTS},
preferredLocale: {
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
},
})(SignInPage);

0 comments on commit b64fd34

Please sign in to comment.