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

feat: Added scripts and marked strings for i18n. #396

Merged
merged 1 commit into from
May 21, 2024

Conversation

saleem-latif
Copy link
Contributor

Jira Ticket: ENT-8580

Description:
This PR adds i18n support for catalog-search package.

Merge checklist:

  • Evaluate how your changes will impact existing consumers (e.g., frontend-app-learner-portal-enterprise, frontend-app-admin-portal, and frontend-app-enterprise-public-catalog). Will consumers safely be able to upgrade to this change without any breaking changes?
  • Ensure your commit message follows the semantic-release conventional commit message format. If your changes include a breaking change, ensure your commit message is explicitly marked as a BREAKING CHANGE so the NPM package is released as such.
  • Once CI is passing, verify the package versions that Lerna will increment to in the Github Action CI workflow logs.
    • Note: This may be found in the "Preview Updated Versions (dry run)" step in the Github Action CI workflow logs.

Post merge:

  • Follow the release steps in the README documentation. Verify Lerna's release commit (e.g., chore(release): publish new versions) that incremented versions in relevant package.json and CHANGELOG files, and created Git tags for those versions is on master (Important: ensure the Git tags are for the correct commit SHA).
  • Run the Publish from package.json Github Action workflow to publish these new package versions to NPM.
    • This may be triggered by clicking the "Run workflow" option for the master branch.
  • Verify the new package versions were published to NPM (i.e., npm view <package_name> versions --json).
    • Note: There may be a slight delay between when the workflow finished and when NPM reports the package version as being published. If it doesn't appear right away in the above command, try again in a few minutes.

@saleem-latif saleem-latif self-assigned this May 17, 2024
@saleem-latif saleem-latif force-pushed the saleem-latif/ENT-8580 branch 3 times, most recently from 4e36443 to cb2edf1 Compare May 17, 2024 09:32
packages/catalog-search/package.json Outdated Show resolved Hide resolved
} from './data/constants';
import {
useActiveRefinementsAsFlatArray,
} from './data/hooks';
import { SearchContext } from './SearchContext';
import { removeFromRefinementArray, deleteRefinementAction } from './data/actions';

const messages = defineMessages({
[LEARNING_TYPE_COURSE]: {
id: 'search.facetFilters.filterTitle.course',
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not following Camel case format in IDs of strings. So I think, we can maintain the consistency as we are doing in learner portal and admin portal.
search.facetFilters.filterTitle.course -> search.facet.filters.filter.title.course

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is better to use dot . to separate pages/components and use camelCase for page/component name.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, camelCase is preferred for message ids.

description: 'Title for the course filter.',
},
[LEARNING_TYPE_PROGRAM]: {
id: 'search.facetFilters.filterTitle.program',
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as mentioned above about id format

description: 'Title for the program filter.',
},
[LEARNING_TYPE_PATHWAY]: {
id: 'search.facetFilters.filterTitle.pathway',
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as mentioned above about id format. And please do it on otherwise her places too.

@saleem-latif saleem-latif force-pushed the saleem-latif/ENT-8580 branch from cb2edf1 to 59ce78b Compare May 17, 2024 10:00
@saleem-latif saleem-latif requested a review from macdiesel May 17, 2024 10:04
} from './data/constants';
import {
useActiveRefinementsAsFlatArray,
} from './data/hooks';
import { SearchContext } from './SearchContext';
import { removeFromRefinementArray, deleteRefinementAction } from './data/actions';

const messages = defineMessages({
[LEARNING_TYPE_COURSE]: {
id: 'search.facetFilters.filterTitle.course',
Copy link
Member

Choose a reason for hiding this comment

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

Agreed, camelCase is preferred for message ids.

@@ -42,6 +43,10 @@ const SearchData = ({ children, searchFacetFilters, trackingName }) => {
refinementsReducer,
{},
);
const intl = useIntl();
const searchFacetFiltersWithI18n = (
searchFacetFilters === null ? getSearchFacetFilters(intl) : searchFacetFilters
Copy link
Member

Choose a reason for hiding this comment

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

nit: might make sense to check for falsey (i.e., not explicitly checking for null). E.g., if someone were to pass searchFacetFilters={undefined} as the prop.

Might also make sense to reverse the ordering of your conditional.

const searchFacetFiltersWithI18n = searchFacetFilters || getSearchFacetFilters(intl);

nit x2: If searchFacetFilters is passed as a prop, there's not actually a guarantee the search filters are using i18n messages; they could be passed with hardcoded English strings (as Learner Portal is passing today). Is it slightly misleading to have this variable named searchFacetFiltersWithI18n when if custom searchFacetFilters are provided, they may not actually use i18n?

id: 'catalog.search.pagination.page.of.count',
defaultMessage: 'of',
description: 'Label for the page of count in the pagination component',
}),
Copy link
Member

Choose a reason for hiding this comment

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

[clarification] Is the intent of this PR to migrate all hardcoded English strings? If so, should we also be migrating the following hardcoded English strings?

@saleem-latif saleem-latif force-pushed the saleem-latif/ENT-8580 branch from 59ce78b to af685c9 Compare May 20, 2024 08:15
@saleem-latif
Copy link
Contributor Author

@adamstankiewicz I have made changes according to your feedback, please take another look.

@saleem-latif saleem-latif merged commit a0fb639 into master May 21, 2024
5 checks passed
@saleem-latif saleem-latif deleted the saleem-latif/ENT-8580 branch May 21, 2024 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants