First, I got String Table imported with CSV and I want to apply translation to TMP text UIs.
Starting with a TMP Text object I have selected, there’s no Game Object Localizer at first. Right?
I hvae to change the text field using the recording feature of Localization Scene Controls window, it adds Game Object Localizer component and generates a new entry in the String table, which I don’t need because I already have entry for the Text UI.
Now what I have to do for the UI and the new garbage entry, is two things:
-changing the Text property to the entry I want
-removing the newly added entry from the table
Thinking of working with many Text UIs, I am already tired of it.
Now let’s say I don’t use the Localization Scene Controls window for this matter. I tried to just add Game Object Localizer then add Tracked Properties - Text for my entry.
Unfortunately, there’s no way to assign the entries I have already got.
It would be nice if anyone let me know a workaround to avoid messing around my String Table.
Many thanks always.
Hey sorry to hear this. The idea was that you would be adding the text as you go and so adding new entries would feel more seamless. We do have plans on our roadmap to introduce a way to link properties without having to modify them through the scene.
For now, you could write a script to make it easier by automatically adding the link.
This will do it:
using TMPro;
using UnityEditor;
using UnityEngine.Localization.PropertyVariants;
using UnityEngine.Localization.PropertyVariants.TrackedObjects;
using UnityEngine.Localization.PropertyVariants.TrackedProperties;
public class AutoLinkTMP
{
[MenuItem("CONTEXT/TextMeshProUGUI/Localize (With Localized Properties)")]
static void LocalizeTMProText(MenuCommand command)
{
var target = command.context as TextMeshProUGUI;
var localizer = target.gameObject.GetComponent<GameObjectLocalizer>() ?? target.gameObject.AddComponent<GameObjectLocalizer>();
var trackedObject = localizer.GetTrackedObject<TrackedUGuiGraphic>(target, create: true);
var trackedProp = trackedObject.AddTrackedProperty<LocalizedStringProperty>("m_text");
trackedProp.LocalizedString.SetReference("My Table", "My Entry");
}
}
Now click the TMP context menu and choose Localize (With Localized Properties) to add and set up the component automatically.
Don’t know if it’s new, but you can add a GameObjectLocalizer component and then go “rightclick->localize property” on a text field to make it localized without creating some empty table entry. On the GameObjectLocalizer you can then select whatever entry you want.
Not sure if that’s the intended workflow, but it works for me.