Actually, theme settings are accessible from CSS but not theme translations.
Would be nice to make it translatable
For example, in DiscoTOC theme component, we have this setting:
used in css:
Actually, theme settings are accessible from CSS but not theme translations.
Would be nice to make it translatable
For example, in DiscoTOC theme component, we have this setting:
used in css:
Adding text via CSS is kind of a last resort workaround because it’s not accessible, I don’t think we should encourage it by supporting it with additional features.
Could such a thing be achievable through a plugin though?
A plugin to enable translations in SCSS… anything is possible, but it would be very messy. For example, you would somehow need to compile different CSS assets for each locale. I would strongly recommend not trying to do this.
One possible idea… but not a recommendation (i.e. you’re on your own if you attempt this
)
You could do something like this in the theme javascript
document.documentElement.style.setProperty('--my-translation-name', `"${ I18n.t(themePrefix("my-translation-name")) }"`);
And then in the css
&:before {
content: var(--my-translation-name);
}
This could break in many ways - if you put a quote or special characters in the translation it will break. If you try and use it in IE11, it will break.
I also don’t support making translations accessible in theme CSS ![]()
As for the example in your post @evantill, that’s going to be removed in the next update for that theme component.
This topic was automatically closed after 3 hours. New replies are no longer allowed.