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

Spike: Support for internationalization (i18n) #2615

Closed
6 tasks done
denyo opened this issue Jun 22, 2023 · 0 comments · May be fixed by #3004
Closed
6 tasks done

Spike: Support for internationalization (i18n) #2615

denyo opened this issue Jun 22, 2023 · 0 comments · May be fixed by #3004
Assignees
Labels
a11y community community request component Adds or changes of the components
Milestone

Comments

@denyo
Copy link
Contributor

denyo commented Jun 22, 2023

Scope

Currently the possibilities for internationalization, e.g. translation of wordings, is quite limited.

Only p-pagination and p-carousel offer something via their intl prop.
Some other components provide the aria prop where an aria-label can be set.

Others, like p-modal and p-inline-notification don't offer any possibility to translate their dismiss buttons.
As brought up here, p-pagination's intl isn't flexible enough to allow correct wordings/aria-labels for other languages like they are used in Japan, Korea and Latvia, where the page number would be in the middle of two characters/words like 第2頁.

Let's come up with a solution that works for all components.

Notes

Acceptance criteria

  • A proposal is worked out on how PDS components support standardized internationalization

Subtasks

Results

  • consumer should be able to change translations since
    • even if we could cover all relevant languages there might still be need to customize
    • add another language/dialect
    • lazy loading translations
  • local overrides on per component level should be possible
  • global defaults possible to set via provider/module
  • interpolation via {{value}} seems to be supported by most i18n libraries except vue which uses {value} which could be handled with a replacement on provider level which would be good for consistency from a team's or translator's perspective
  • tools for translating
  • components with wordings (see component-meta for a list of extracted wordings)
    • p-flyout
    • p-flyout-navigation
    • p-flyout-navigation-item
    • p-inline-notification
    • p-modal
    • p-multi-select
    • p-popover
    • p-select-wrapper-dropdown
    • p-text-field-wrapper
    • p-toast-item
    • p-wordmark
    • keep in mind parent component might need to forward it, e.g. p-banner using p-inline-notification internally
  • components with intl prop
    • p-carousel (Override the default wordings that are used for aria-labels on the next/prev buttons and pagination.)
{
  prev: 'string', 
  next: 'string',
  first: 'string',
  last: 'string',
  slideLabel: 'string',
  slide: 'string',
}
  • p-pagination (Override the default wordings that are used for aria-labels on the next/prev and page buttons.)
{
  root: 'string',
  prev: 'string',
  next: 'string',
  page: 'string',
}
  • components with aria prop
    • p-button
    • p-button-pure
    • p-button-tile
    • p-carousel
    • p-crest
    • p-flyout
    • p-flyout-navigation
    • p-icon
    • p-link
    • p-link-pure
    • p-link-tile
    • p-marque
    • p-modal
    • p-pagination
    • p-popover
    • p-scroller
    • p-spinner
    • p-tag-dismissible
    • p-wordmark

Questions

  • singular/plural handling relevant? ––> not so far and kind of unlikely for atomic components
  • bundling in core chunk vs component chunks? ––> irrelevant since handled on application level
  • interpolation (= merging translations with variables) with multiple values? ––> currently not relevant for the extracted wordings, but seems required for p-pagination's intl prop, e.g. 第2頁 which would easily be possible via {{value}} replacement, however more tricky for more than one value (see i18n libraries above for possible solutions)

Conclusion

  • intl and aria prop have some overlap since both are only relevant for aria-* attributes and should probably be merged together since it is somewhat confusing
  • this is somewhat different from the "hidden" wordings that we want to customize here, so introducing a new prop translations or wordings (probably better since this is what the prop supplies, not a translation for different languages/locales)
  • we still need the current default as a fallback, in case of someone trying to customize it with ""
  • ideally we introduce a components prop on PorscheDesignSystemProvider and option on PorscheDesignSystemModule where the default values for props can be configured for each component (for now, maybe just for translations or wordings or whatever we want to call it)
  • components that don't have a configurable prop, should not show up
  • this allows global or per module configuration with local overrides where needed
  • consuming teams then need to either specify the wordings on a per component basis (or wrap it in their own component) or map their wordings to our config, this way we are compatible with plain html and frameworks no matter which i18n library
  • ideally all wordings should be extracted and have their customizability be verified via component-meta and documented/explained
  • drafted example for p-inline-notification and react: https://github.com/porsche-design-system/porsche-design-system/pull/3004/files

Final Conclusion

  • intl prop gets deprecated
  • we don't add a new translations or wordings prop
  • we add/extend aria props since currently all values affect screen readers only
  • draft for p-pagination
  /**
   * @deprecated since v3.10.0 use `aria` instead
   * Override the default wordings that are used for aria-labels on the next/prev and page buttons. */
  @Prop() public intl?: PaginationInternationalization = {
    root: 'Pagination',
    prev: 'Previous page',
    next: 'Next page',
    page: 'Page',
  };

  @Prop() public aria?: SelectedAriaAttributes<'aria-label'> & {
    prev: SelectedAriaAttributes<'aria-label'>;
    next: SelectedAriaAttributes<'aria-label'>;
    page: SelectedAriaAttributes<'aria-label'>;
  } = {
    'aria-label': 'Pagination',
    prev: { 'aria-label': 'Previous page' },
    next: { 'aria-label': 'Next page' },
    page: { 'aria-label': 'Page' },
  };
@denyo denyo added component Adds or changes of the components to be refined issue has to be refined community community request labels Jun 22, 2023
@stephanschroeter stephanschroeter added this to the Components milestone Jun 28, 2023
@stephanschroeter stephanschroeter changed the title Support for internationalization (i18n) Spike: Support for internationalization (i18n) Dec 4, 2023
@stephanschroeter stephanschroeter removed the to be refined issue has to be refined label Jan 9, 2024
@denyo denyo self-assigned this Jan 22, 2024
@denyo denyo assigned stephanschroeter and marcelbertram and unassigned denyo Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y community community request component Adds or changes of the components
Projects
Archived in project
3 participants