Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-4366: Change languages in my account panel to sentence case #1277

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/apps/esm-primary-navigation-app/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
},
transformIgnorePatterns: [],
moduleNameMapper: {
'lodash-es/(.*)': 'lodash/$1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is post-commit, but the reason that this rule didn't exist is because we want you to use import { captialize } from 'lodash-es'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@denniskigen denniskigen Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must've got this lopsided, sorry, @harshthakkr.

I thought we preferred import capitalize from 'lodash-es/capitalize' @ibacher

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here

Copy link
Member

@ibacher ibacher Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With lodash, but not lodash-es that was the case. lodash-es is packaged as a ES Module whereas lodash is, I think, common-js, so importing import {capitalize} from 'lodash' ends up including all of lodash, but import {capitalize} from 'lodash-es' only imports the relevant parts of lodash-es—which is exactly what import capitalzie from 'lodash/capitalize' also accomplishes.

'lodash-es': 'lodash',
'@openmrs/esm-framework': '@openmrs/esm-framework/mock.tsx',
'\\.(s?css)$': 'identity-obj-proxy',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, SwitcherItem } from '@carbon/react';
import capitalize from 'lodash-es/capitalize';
import { TranslateIcon, showModal, useSession } from '@openmrs/esm-framework';
import styles from './change-language-link.scss';

Expand All @@ -22,7 +23,7 @@ function ChangeLanguageLink() {
<SwitcherItem className={styles.panelItemContainer} aria-label={t('changeLanguage', 'Change language')}>
<div>
<TranslateIcon size={20} />
<p>{languageNames.of(session?.locale)}</p>
<p>{capitalize(languageNames.of(session?.locale))}</p>
</div>
<Button kind="ghost" onClick={launchChangeLanguageModal}>
{t('change', 'Change')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { capitalize } from 'lodash-es';
import {
Button,
InlineLoading,
Expand All @@ -10,6 +9,7 @@ import {
RadioButton,
RadioButtonGroup,
} from '@carbon/react';
import capitalize from 'lodash-es/capitalize';
import { useConnectivity, useSession } from '@openmrs/esm-framework';
import { postUserPropertiesOffline, postUserPropertiesOnline } from './change-language.resource';
import styles from './change-language.scss';
Expand Down
Loading