Hey everyone 👋
I’m using Payload CMS with localization enabled. After enabling it, the locale switcher appears globally in the admin UI, which is expected.
However, my admin panel is role-based:
service-provider → offers collection
client → orders collection
admin → pages collection with page builder
Localization only for the pages collection
Locale switcher visible only to admins (or only when viewing specific collections)
I couldn’t find any config option for controlling the Localization Switcher in admin.components or custom root components.
Is there an official way to control or disable the default locale switcher?
Can it be scoped per role or per collection?
Would the best approach be hiding the default switcher and injecting a custom one only on the Pages collection view?
Any guidance or best practices would be appreciated 🙏
Currently Payload doesn't have a built-in way to conditionally show/hide the locale switcher
Isn't [filtering available locales](
https://payloadcms.com/docs/configuration/localization#filter-available-options) sufficient?
To hide it completely I'd suggest a new prop in the config to the Payload team.
A workaround I can think of would be to add some simple css in
custom.scssto hide it. For example:
.payload-localizer-wrapper[data-user-role="service-provider"] .localizer,
.payload-localizer-wrapper[data-user-role="client"] .localizer {
display: none;
}And then create a JSX component, maybe a provider and inject the
data-user-roleattribute on the body.
export const LocalizerControlProvider = ({ children }) => {
const { user } = useAuth()
return (
<div className="payload-localizer-wrapper" data-user-role={user?.role}>
{children}
</div>
)
}Add this via
admin.components.providersin your config.
Just some pseudo code, you can change the data attributes and values accordingly, for example extract what collection the user currently is visiting and updating accordingly
Thank you! that’s exactly what I needed 🙏
I hadn’t thought about using a data attribute + CSS, but that’s actually a really elegant approach.
With this workaround, the localization problem is completely solved for my use case. Thanks a lot for the idea and the clear explanation!
Star
Discord
online
Get dedicated engineering support directly from the Payload team.