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: Print a warning when both I18nProvider and own i18n string are missing #3172

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

just-boris
Copy link
Member

Description

Add a warning to help developers understand what is happening

Related links, issue #, if available: n/a

How has this been tested?

  1. Added a unit test
  2. Manually visited dev pages, addressed some apparently missing strings (but not all)
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

recoveryText,
errorIconAriaLabel,
getRecoveryText: () => i18n('errorIconAriaLabel', restProps.errorIconAriaLabel),
getErrorIconAriaLabel: () => i18n('recoveryText', restProps.recoveryText),
Copy link
Member Author

Choose a reason for hiding this comment

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

Make recovery text and error label lazy-loadable, only when this feature is used

Comment on lines +28 to +31
warnOnce(
component,
`Localization is not provided for key ${key}. Provide the value as a prop or use I18nProvider`
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the change. Everything else is to fix appeared warnings

Comment on lines -40 to -52
statusType,
empty,
loadingText,
finishedText,
filteringResultsText,
errorText,
recoveryText,
isEmpty,
isNoMatch,
isFiltered,
noMatch,
hasRecoveryCallback,
onRecoveryClick,
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no point to destructure the object in a type declaration

@@ -209,21 +202,6 @@ export function useMultiselect({
renderHighlightedAriaLive,
});

const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused code, there is a duplicate of this

const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({
label: option.label,
disabled: disabled || option.disabled,
labelTag: option.labelTag,
description: option.description,
iconAlt: option.iconAlt,
iconName: option.iconName,
iconUrl: option.iconUrl,
iconSvg: option.iconSvg,
tags: option.tags,
dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>
format({ option__label: option.label ?? '' })
),
}));

Comment on lines +167 to +168
getErrorIconAriaLabel: () => undefined,
getRecoveryText: () => props.recoveryText,
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no i18n support for these strings in property filter. I will create a follow up ticket for that

@just-boris just-boris force-pushed the missing-i18n-warning branch from 93abc01 to 09e8751 Compare January 7, 2025 18:10
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.40%. Comparing base (f7988a7) to head (09e8751).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3172      +/-   ##
==========================================
- Coverage   96.40%   96.40%   -0.01%     
==========================================
  Files         784      784              
  Lines       22138    22150      +12     
  Branches     7592     7201     -391     
==========================================
+ Hits        21343    21354      +11     
- Misses        788      789       +1     
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +189 to +190
getRecoveryText: () => i18n('errorIconAriaLabel', restProps.errorIconAriaLabel),
getErrorIconAriaLabel: () => i18n('recoveryText', restProps.recoveryText),
Copy link
Member

Choose a reason for hiding this comment

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

The property names seem to have gotten mixed up here

Suggested change
getRecoveryText: () => i18n('errorIconAriaLabel', restProps.errorIconAriaLabel),
getErrorIconAriaLabel: () => i18n('recoveryText', restProps.recoveryText),
getRecoveryText: () => i18n('recoveryText', restProps.recoveryText),
getErrorIconAriaLabel: () => i18n('errorIconAriaLabel', restProps.errorIconAriaLabel),

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