Skip to content

Commit

Permalink
STCOR-851 accept locale from stripes-config (#1476)
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 authored Jun 10, 2024
1 parent d1cdfa8 commit 83afa6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844..
* Update session data with values from `_self` request on reload. Refs STCOR-846.
* Avoid deprecated `getChildContext`. Refs STCOR-842.
* 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 @@ -77,8 +77,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 @@ -114,7 +115,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 @@ -241,8 +241,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 83afa6b

Please sign in to comment.