-
Notifications
You must be signed in to change notification settings - Fork 179
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
refactor(protocol-designer): migrate i18n instances to use useTranslation hook #14326
Conversation
6fd4a7b
to
8e59572
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## edge #14326 +/- ##
==========================================
- Coverage 68.13% 68.05% -0.09%
==========================================
Files 2512 2505 -7
Lines 71478 71621 +143
Branches 9077 9084 +7
==========================================
+ Hits 48705 48739 +34
- Misses 20670 20772 +102
- Partials 2103 2110 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -41,7 +41,7 @@ | |||
"react-dnd": "6.0.0", | |||
"react-dnd-mouse-backend": "0.1.2", | |||
"react-dom": "18.2.0", | |||
"react-i18next": "13.5.0", | |||
"react-i18next": "14.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess If 13.5.0 works for PD, it will be good to keep the same version as well as app
.
Also, we could move these two packages into the top level package.json
like app-shell and app-shell-odd do.
protocol-designer/src/components/BatchEditForm/NoBatchEditSharedSettings.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/BatchEditForm/BatchEditMoveLiquid.tsx
Outdated
Show resolved
Hide resolved
</a> | ||
<a className={styles.overlay_button} onClick={deleteLabware}> | ||
{!isOver && <Icon className={styles.overlay_icon} name="close" />} | ||
{i18n.t('deck.overlay.edit.delete')} | ||
{'Delete'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question
Any specific reason to pass the word directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll fix this in a follow up pr where i remove the usage of all connect functions. I think i was lazy here and just changed it to not using i18n 😓
protocol-designer/src/components/StepEditForm/fields/MixFields.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/StepEditForm/fields/PipetteField.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/StepEditForm/fields/TipPositionField/TipPositionModal.tsx
Show resolved
Hide resolved
@@ -37,37 +37,53 @@ export interface WellOrderModalProps { | |||
firstValue?: WellOrderOption | null, | |||
secondValue?: WellOrderOption | null | |||
) => void | |||
t: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, we need to upgrade packages...
https://www.i18next.com/overview/typescript
Could you leave a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, for some reason the t was typing as any so i left it as any whenever i needed to use it as a prop. I'll link this url in the comment!
protocol-designer/src/components/StepEditForm/fields/WellSelectionField/WellSelectionField.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/StepEditForm/forms/PauseForm.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/StepEditForm/forms/TemperatureForm.tsx
Outdated
Show resolved
Hide resolved
@@ -36,21 +37,20 @@ export const ErrorContents = ( | |||
case 'NO_TIP_ON_PIPETTE': | |||
return ( | |||
<> | |||
{i18n.t(`alert.timeline.error.${props.errorType}.body1`)} | |||
{t(`timeline.error.${props.errorType}.body1`)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe deconstruct props
in the future?
protocol-designer/src/components/labware/BrowseLabwareModal.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/modals/CreateFileWizard/__tests__/CreateFileWizard.test.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/modals/CreateFileWizard/__tests__/GoBack.test.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/modals/CreateFileWizard/__tests__/ModulesAndOtherTile.test.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/modals/FilePipettesModal/PipetteFields.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/modals/FilePipettesModal/index.tsx
Outdated
Show resolved
Hide resolved
protocol-designer/src/components/modals/FileUploadMessageModal/FileUploadMessageModal.tsx
Outdated
Show resolved
Hide resolved
import { selectors as loadFileSelectors } from './load-file' | ||
|
||
export const initialize = (store: Record<string, any>): void => { | ||
if (process.env.NODE_ENV === 'production') { | ||
window.onbeforeunload = (_e: unknown) => { | ||
// NOTE: the custom text will be ignored in modern browsers | ||
return loadFileSelectors.getHasUnsavedChanges(store.getState()) | ||
? i18n.t('alert.window.confirm_leave') | ||
? 'Are you sure you want to leave? You will lose any unsaved changes.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need to add this text to a json file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not sure how to import the useTranslation hook here since this const is used to initialize redux. I left a comment to go back to it though. After all the connect fns are refactored out, i can do an audit of the remainder text that is not in i18n yet.
|
||
export const getModuleShortNames = (type: ModuleType): string => { | ||
switch (type) { | ||
case 'heaterShakerModuleType': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe importing const from shared-data
would be good?
import {
HEATERSHAKER_MODULE_TYPE,
MAGNETIC_MODULE_TYPE,
TEMPERATURE_MODULE_TYPE,
THERMOCYCLER_MODULE_TYPE
} from ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the smoke test and didn't see any typical text display issue on PD.
Thank you for converting class component -> functional component! That is awesome.
closes RAUT-542
Overview
This PR fixes all instances of i18n in the protocol-designer directory by using the
useTranslation
hook instead. This is because the previous way we were doing it wasn't properly implementingreact-i18next
.Additionally, several usages of the class components + connect function were refactored in order to use the
useTranslation
hook properly (this is part of a chore that needs to be done anyway to remove all the class components)Test Plan
Smoke test PD, try to go through every flow as much as possible and call out anything that doesn't work correctly or whitescreens.
Here is the sandbox to smoke test on: https://sandbox.designer.opentrons.com/pd_update-i18n/
Changelog
i18next
andreact-i18next
dependencies to be the latestReview requests
see test plan
Risk assessment
medium-ish since it touches a bunch of code but it'll be internal