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

[no-Jira] Localize labels and use static translation strings #856

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

canac
Copy link
Contributor

@canac canac commented Jan 17, 2024

Description

Translation labels need to be static strings so that i18next can reliably extract them from our source code. We can't do t(status), t(condition ? 'label1' : 'label2'), or t(`Interpolated label with ${value}`).

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@canac canac added the On Staging Will be merged to the staging branch by Github Actions label Jan 17, 2024
@canac canac requested review from caleballdrin and dr-bizz January 17, 2024 16:40
@@ -134,7 +135,7 @@ const SearchMenu = (): ReactElement => {
{
name: t('Reports - Donations'),
icon: <CompassIcon />,
link: `/accountLists/${accountListId}/reports/PartnerGivingAnalysis`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old link 404s.

@@ -44,8 +42,8 @@ export const Item: React.FC<Props> = ({
variant: 'subtitle1',
color: 'textPrimary',
}}
primary={t(item.title)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Localization is done in MultiPageMenuItems.ts

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-856.d3dytjb8adxkk5.amplifyapp.com

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

This looks great! I left a few remarks but nothing crazy. I've requested some changes, but feel free to talk or disagree.

return (
<DragLayerStatusBox width={width}>
<Typography>{t(status)}</Typography>
<Typography>{status}</Typography>
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't tried this one, but if it's anything like ContactFlowSetupStatusRow it needs to be wrapped in the t function.

Suggested change
<Typography>{status}</Typography>
<Typography>{t(status)}</Typography>

@@ -58,7 +56,7 @@ export const ContactFlowSetupStatusRow: React.FC<Props> = ({
}, []);
return (
<StatusRow {...{ ref: drag }} data-testid={status.id}>
<Typography>{t(status.value)}</Typography>
<Typography>{status.value}</Typography>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Typography>{status.value}</Typography>
<Typography>{t(status.value)}</Typography>

@@ -82,7 +82,7 @@ export const AddMenuPanel = (): ReactElement => {
<LeafListItem key={index} disableGutters onClick={onClick}>
<LeafButton style={style}>
<Icon size={18} style={iconStyle} />
<Title>{t(text)}</Title>
<Title>{text}</Title>
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is so react i18 can pick up the phases to send to OneSky.

Copy link
Contributor

Choose a reason for hiding this comment

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

While you're editing this file, is it worth to cleaning up lines 23, 24, 25 & 26 imports. Removing ../../../../../../

@canac
Copy link
Contributor Author

canac commented Jan 23, 2024

@dr-bizz You are right about my changes to the navigation items and flows breaking things, so I went ahead and reverted them. Somehow those labels are manually in the translation files. While it would be ideal for all of our labels to be static strings, I don't want to break anything or spend too much more time on this.

@canac canac requested a review from dr-bizz January 23, 2024 17:21
@dr-bizz
Copy link
Contributor

dr-bizz commented Jan 25, 2024

codeCov is failing, but try merging main into this branch. that might help with the scores.

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

Awesome work! 🔥🔥

@canac canac removed the On Staging Will be merged to the staging branch by Github Actions label Jan 25, 2024
@canac canac merged commit 6ee1ac8 into main Jan 25, 2024
18 checks passed
@canac canac deleted the localize-labels branch January 25, 2024 21:30
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.

2 participants