Skip to content

Commit

Permalink
STCOR-851 accept locale from stripes-config
Browse files Browse the repository at this point in the history
Allow `stripes.config.js` to set `config.locale` in order to override
the default value, `en-US`. This allows a tenant to set the locale for
pages that are displayed before authenticating, when the tenant's locale
can be read from mod-configuration.

The `stripes.config.js` value will be overwritten by the stored value
from mod-configuration, if present.

Refs STCOR-851
  • Loading branch information
zburke committed May 22, 2024
1 parent 05badf9 commit a99d64e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* Make branding optional. Refs STCOR-847.
* Idle-session timeout and "Keep working?" modal. Refs STCOR-776.
* Implement password validation for Login Page. Refs STCOR-741.
* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844..
* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844.
* Read locale from stripes-config before defaulting to `en-US`. Refs STCOR-851.

## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-12)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.0...v10.1.0)
Expand Down
6 changes: 2 additions & 4 deletions src/components/Root/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ class Root extends Component {
}

componentDidMount() {
const { okapi, store, locale, defaultTranslations } = this.props;
const { okapi, store, defaultTranslations } = this.props;
if (this.withOkapi) checkOkapiSession(okapi.url, store, okapi.tenant);
const locale = this.props.config.locale ?? 'en-US';
// TODO: remove this after we load locale and translations at start from a public endpoint
loadTranslations(store, locale, defaultTranslations);
}
Expand Down Expand Up @@ -122,7 +123,6 @@ class Root extends Component {

render() {
const { logger, store, epics, config, okapi, actionNames, token, isAuthenticated, disableAuth, currentUser, currentPerms, locale, defaultTranslations, timezone, currency, plugins, bindings, discovery, translations, history, serverDown } = this.props;

if (serverDown) {
return <div>Error: server is down.</div>;
}
Expand Down Expand Up @@ -254,8 +254,6 @@ Root.propTypes = {

Root.defaultProps = {
history: createBrowserHistory(),
// TODO: remove after locale is accessible from a global config / public url
locale: 'en-US',
timezone: 'UTC',
currency: 'USD',
okapiReady: false,
Expand Down

0 comments on commit a99d64e

Please sign in to comment.