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

Allow to configure "aria-label" values inside components (ie. <Modal />) #1458

Open
2 tasks done
kcmr opened this issue Jul 30, 2024 · 3 comments
Open
2 tasks done

Allow to configure "aria-label" values inside components (ie. <Modal />) #1458

kcmr opened this issue Jul 30, 2024 · 3 comments
Labels
🐛 bug Something isn't working confirmed This bug was confirmed

Comments

@kcmr
Copy link

kcmr commented Jul 30, 2024

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

Summary

I'm using the <Modal> component and I would like to be able to customize the close button label (aria-label attribute) for other languages appart from english. Right now, the close button label is hardcoded to Close.

I've seen that there are multiple components where the aria-label attribute is hardcoded to english, so I think it would be a good idea to make it customizable.

If you have any ideas on how to implement this, I'd be happy to help with a contribution.

@rluders rluders added 🐛 bug Something isn't working confirmed This bug was confirmed labels Aug 14, 2024
@vaidikpatil5
Copy link

can i try

@vaidikpatil5
Copy link

vaidikpatil5 commented Sep 11, 2024

Here are four approaches to make the aria-label customizable for different languages:

1.Props-based translation: Pass the translated label as a prop to the ModalHeader component. This is simple and flexible for small projects without needing external libraries.

2.Global context for translations: Create a global context to manage translations and wrap the app or relevant components with a TranslationProvider. This centralizes translation logic and is easy to expand for larger projects.

3.Hardcoded object-based translations: Use a hardcoded object to map language codes to translations. It's lightweight but limited in scalability, suitable for small, simple projects.

  1. React-i18next: Use the react-i18next library for robust localization. It provides a hook (useTranslation) to easily fetch translations and switch languages dynamically. Ideal for projects needing comprehensive localization support.

what spproch should i take @rluders , can u plz guide

@KBeDevel
Copy link

I'm not sure if this is another issue, but Dropdown component prop types allow "aria-label", but this is not included in the trigger button rendering nor in the dropdown menu box.

For example:

<Dropdown
  arrowIcon={false}
  aria-label="Alerts"
  size="sm"
  color="gray"
  inline
  label={...}
  dismissOnClick={false}
>
  ...
</Dropdown>
<button
  id=":rs:"
  class="flex items-center"
  type="button"
  aria-expanded="false"
  aria-haspopup="menu"
  style=""
  aria-controls=":rr:"
  data-floating-ui-inert=""
>
  <div
    style="..."
    data-testid="flowbite-dropdown"
    aria-expanded="true"
    tabindex="-1"
    class="z-10 w-fit divide-y divide-gray-100 ..."
    id=":rr:"
    role="menu"
    aria-labelledby=":rs:"
    aria-orientation="vertical"
  >
    <ul class="py-1 focus:outline-none" tabindex="-1">
        ...
    </ul>
  </div>
</button>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working confirmed This bug was confirmed
Projects
None yet
Development

No branches or pull requests

4 participants