I’ve just stumbled across the new uielements system - it looks like a really nice addition to the editor, thank you! I’ve been playing around with it a bit today and was wondering if there are any best practices in place for storing strings used in the uxml files? It would be great to be able to store them in a key-value file and pass the key to the uxml to keep things neat - is this (or something similar) possible?
For reference; at the moment I’m adding a unique name to all of the labels I’m using and then referencing them in the OnEnable method in the editor script (example below)…it feels pretty clunky after several lines, so I get the feeling I’m going down a bad path…
uxml = new UIElementTestUXML();
uxml.Q(“settings-not-found”).text = string.Format(UIElementTestStrings.SaveSettingsNotFound, UIElementTestStrings.SaveSettingsPath);
Thanks for your response. Rather than inlining the text, my question was whether there was a process for externalising it.
i.e, in the uxml
<ui:Label name=“my-label” key=“component.name.main.header”/>
then have a key-value pair text localisation file that you would load alongside the uxml with the following:
component.name.main.header=Component Header Text
in that way, if building an editor tool for use in multiple countries, it’s possible to specify the language and just switch out the file with the localised text in it. It’s then also easier to reuse common strings and keep a cleaner workflow.
We don’t have any specialized localization support built into UIElements at this time. Your solution is not bad. I would have just used the name property directly instead of deriving a new Label element. You can then assign all “localization ready” Labels a special class and only include those labels in your localization initialization step.