Skip to content

Conversation

yuito-it
Copy link
Contributor

@yuito-it yuito-it commented May 17, 2025

Summary

This PR adds an index.js file under the locales/ directory to explicitly export available locale modules (currently hiIN). This enables imports like:

import { hiIN } from "@toolpad/core/locales";

Motivation

Previously, consumers attempting to import @toolpad/core/locales encountered errors because:

  • The module was implemented as a flat file (hiIN.js)
  • There was no index.js in the locales/ folder
  • The package.json exports field did not expose this path explicitly

but this method matches how Material UI locales are imported.

As a result, valid-looking import paths like:

import { hiIN } from "@toolpad/core/locales";

would fail at runtime

This PR fixes that by introducing an explicit index that re-exports the locales,

Changes

  • Added locales/index.js that re-exports hiIN
  • No locale logic was changed—just improved how they're consumed

Benefits

  • Fixes a broken import path (bugfix)
  • Improves DX by enabling clean, named imports
  • Easy to scale: new locales can be added via the index file

Notes

This fix avoids having to restructure each locale into its own folder or clutter the exports field with specific entries. It keeps the implementation simple while solving a real usability issue.

  • I've read and followed the contributing guide on how to create great pull requests.
  • I've updated the relevant documentation for any new or updated feature.
  • I've added a visual demonstration in the form of a screenshot or video.

@yuito-it yuito-it changed the title Fix/locales Fix Localization May 17, 2025
@yuito-it yuito-it changed the title Fix Localization Fix broken hiIN locale import by adding index entry under /locales May 17, 2025
@mui-bot
Copy link

mui-bot commented May 17, 2025

Netlify deploy preview

https://deploy-preview-4945--mui-toolpad-docs.netlify.app/

Generated by 🚫 dangerJS against 2034709

@yuito-it yuito-it marked this pull request as ready for review May 17, 2025 10:08
@yuito-it
Copy link
Contributor Author

Also I'm going to send anothor PR to translate Japanese, if this PR was merged.

@bharatkashyap bharatkashyap added the i18n Internationalization. The infrastructure used by localization. label May 19, 2025
@bharatkashyap bharatkashyap changed the title Fix broken hiIN locale import by adding index entry under /locales Use named imports for locales May 19, 2025
@bharatkashyap
Copy link
Collaborator

bharatkashyap commented May 19, 2025

Thanks for the contribution! Tested the localization demo with the named import - works

@yuito-it
Copy link
Contributor Author

@bharatkashyap I have a question for you.
When are you going to merge this pull request?
I'm affected by this bug, so I'd like you to merge it quickly.

@bharatkashyap bharatkashyap merged commit ad56961 into mui:master May 21, 2025
15 checks passed
@yuito-it yuito-it deleted the fix/locales branch May 21, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n Internationalization. The infrastructure used by localization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants