We’re making our own localization system for TextElements in UIToolkit but apparently there’s no equivalent of ITextPreprocessor in UIToolkit like we have in TMPro so we’re having difficulty to do this nicely with our parser in uitoolkit.
I reckon that UItoolkit textelements also using TextCore which is the same as TMPro which begs another question, why they’re not exposed like in TMPro?
Thanks & cheers~
Maybe that’s because the UI Toolkit localization (available in 2023.3 aka Unity 6) is based on Unity’s Localization package.
We did create a custom element (ParentLocalizer) that handles the localization of Buttons, Labels, custom TextElement, etc. It’s basically a child element that automatically hooks itself to parent element and listens to localization changes to update it’s hooked element’s text. I will eventually share it on GitHub; but I can’t find a spare time to clean it (well, some of it depends on our project specific things right now).
An example usage in UXML:
An example usage in C#:
It’s actually not a hard thing to do; we set it up when AttachToPanelEvent
is fired. Just move original element as sibling to its parent (with display:none; TextElements with children causes problems with auto sizing, so had to move).
Edit: And also, Unity’s App UI might help too (Unity doesn’t recommend for us to use, but, well, it’s a good framework =))