-
Notifications
You must be signed in to change notification settings - Fork 8
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
Unified strategy for providing localized labels within components #1090
Comments
We need to make sure that the solution is scalable because some components, such as the table will have many strings that need to be localized. For example:
|
Options brainstorming: SlotsCreate slots per localized string on the element. <nimble-table>
<span slot="collapse-all-button-label">Hello World</span>
</nimble-table> Pros:
Cons:
AttributesCreate attribute per localized string on the element. <nimble-table
collapse-all-button-label="Hello World"
></nimble-table> Pros:
Cons:
Design TokensConceptually the localized strings are very similar to the sharing pattern of Design Tokens. Vast majority of the time you want to use the same value (increment button text or collapse button text is not control instance specific) but want to adjust to a global config, i.e. theme or language. But also want to be able to override for specific controls as needed. Create non-css property design tokens, similar to the theme and direction design tokens. <nimble-theme-provider
table-collapse-all-button-label="Hello World"
>
<nimble-table></nimble-table>
</nimble-theme-provider> Pros:
Cons:
|
As part of this PR, we are lowering the threshold for the Lighthouse Accessibility score. This is to allow the collapse-all button to be submitted without it having a localizable label. When we address this issue we need to re-up the threshold to 90. |
The theme provider is a cool idea. Another pro is that we could likely single-source the strings in a way that each SLE app doesn't need their own list that would need to be updated every time Nimble adds a new string. For example, we could create half formed brainstorming👇 That made me realize that it would be cool to have a way for apps to get a list of English Nimble strings that need to be translated. Ideally that list could be imported into the app's localization infrastructure so that they'd automatically get the English version, automatically trigger translation to other languages, and automatically pick up new strings that we add. How do Angular apps extract strings from their dependent libraries? Could we mark up For Blazor, is there a way we could publish a resx file of English strings for apps to translate and then have NimbleBlazor use the translated resx files? |
# Pull Request ## 🤨 Rationale #1090 ## 👩💻 Implementation N/A (HLD and doc updates) ## 🧪 Testing N/A ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
# Pull Request ## 🤨 Rationale Partially addresses #1090 (Angular/Blazor changes will be in subsequent PRs) ## 👩💻 Implementation See the [HLD](https://github.com/ni/nimble/tree/main/specs/labels-and-localization) for the implementation plan for the label providers. This PR creates the LabelProvider classes in nimble-components, and creates/uptakes label DesignTokens in `nimble-banner`, `nimble-number-field`, and `nimble-table` ## 🧪 Testing - Verified that each label appears in the expected spots in the DOM for the affected components. Note that the current labels are mostly not user-visible (except that grouped table columns will now have a 'Grouped' tooltip on that icon in the header). Future table changes (i.e. the column header menu) will introduce new visible label tokens. - Added autotests - For label providers: verify token naming, and that label provider attribute updates result in token updates - For controls using labels: verify that the label token values are used in the controls as expected - Updated [Storybook](https://60e89457a987cf003efc0a5b-tbdnyzeaxa.chromatic.com/) - Each component using labels has a new "Localizable labels" row in their Storybook controls/API section - Under "Tokens" is a new ["Label Providers" section](https://60e89457a987cf003efc0a5b-tbdnyzeaxa.chromatic.com/?path=/docs/tokens-label-providers--docs). Each label provider has a section with a table that has the token name, JS property name, HTML attribute name, and English default value of the label. ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed. - Updated nimble-components Readme and Contributing docs with Localization sections.
# Pull Request ## 🤨 Rationale Partially addresses #1090 (Blazor changes will be a subsequent PR) ## 👩💻 Implementation See the [HLD](https://github.com/ni/nimble/tree/main/specs/labels-and-localization) for the implementation plan for the label providers. This PR adds in nimble-angular: - `NimbleLabelProviderCoreDirective` and `NimbleLabelProviderTableDirective` (standard wrappers) - `NimbleLabelProviderCoreWithDefaultsDirective` and `NimbleLabelProviderCoreWithDefaultsDirective`: Apps will use these directives to automatically initialize the label providers with the localized strings (which use `$localize` from `@angular/localize`, which is now an optional peer dependency for nimble-angular) - 2 new secondary entry points, `@ni/nimble-angular/label-provider/core` and `@ni/nimble-angular/label-provider/table` - In my prototype, until I added separate entry points, as soon as an app pulled in new nimble-angular version, Nimble's localized strings would be pulled into their resource files (even without depending on the new modules). Whereas, with secondary entry points, the app needs to explicitly import `NimbleLabelProviderCoreModule` and/or `NimbleLabelProviderTableModule` to get the strings pulled in, which seemed like better behavior. ## 🧪 Testing - Added autotests for new directives - Update Angular example app to pull in the label providers the same way apps will, i.e. `<nimble-label-provider-core withDefaults></nimble-label-provider-core>`. Note that there's not additional translation logic in the example app though, so this just uses the English strings (so basically a no-op, just there as an example). ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed. - Updated Readme and contributing docs for nimble-angular with Localization info
# Pull Request ## 🤨 Rationale Partially addresses #1090 (a few small followup items remain in the work item once Angular/Blazor PRs go in) ## 👩💻 Implementation See the [HLD](https://github.com/ni/nimble/tree/main/specs/labels-and-localization) for the implementation plan for the label providers. The Blazor integration is fairly rudimentary (just the label provider APIs). To fully use them in a Blazor app, the client apps need to handle localizing the strings themselves, as outlined in the Readme updates. ## 🧪 Testing Added basic autotests. Added label providers to example app MainLayout (matches guidance from the Readme). ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed. - Updated Readme to add Localization guidance. Also added brief guidance on NimbleThemeProvider since it wasn't mentioned in this Readme.
# Pull Request ## 🤨 Rationale Follow-up tech debt from adding the label providers (#1090). The banner's close button text can now be controlled by the `popupDismiss` label on `nimble-label-provider-core`, so the `dismissButtonLabel` property on `nimble-banner` is no longer needed. We decided to remove the property in [PR discussion on #1328](#1328 (comment)). ## 👩💻 Implementation Remove property and update tests. ## 🧪 Testing Updated autotests / Storybook. ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
# Pull Request ## 🤨 Rationale Resolves #1090 In [PR discussion on #1272](#1272 (comment)), we decided that the per-component accessibility notes would be better documented in Storybook (by the other component docs), instead of in accessibility.md. Resolves #1393 ## 👩💻 Implementation For components with accessibility notes not already documented in Storybook: - Create an mdx docs page for them, if it wasn't already present. Based on PR comments on the recent PR by Jesse, I think this is the general direction we're going for component docs. - Add a Usage Docs / Accessibility section at the bottom, and add the notes from accessibility.md. The button/spinner mdx have these sections, so again following the existing patterns. ## 🧪 Testing Manual verification in Storybook. ## ✅ Checklist - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
🧹 Tech Debt
Labels for Icons
There are several places where components display icons. Each of these might benefit from:
title
so that sighted users can hover over them to see the icon explained in a tooltiparia-label
or other attributes so that screen reader users can understand their purposeThose strings should be localized. Since we've decided that localization is an application concern and not a Nimble concern, we need to provide (hopefully consistent) APIs for clients to supply these strings.
We may also decide not to set
title
and to exclude the icon from the accessibility tree if its meaning is provided in other ways. We should consult with Leslie and with web best practice docs to come up with guidance for this.The icons we've identified so far:
This will also inform related work like the following, though the solution might be different:
Other Labels in Nimble Components
We also have other labels in Nimble components that will need a way for clients to localize them, such as the banner dismiss button, buttons (expand/collapse group, collapse all groups, etc) in the table, and menu items in the table.
Goals
Possible Implementations
See HLD: #1272
Tasks
The text was updated successfully, but these errors were encountered: