Localize usable overrides with Unity's localization

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Localize usable overrides with Unity's localization

Post by Pixelf0x3 »

Hello!

Im using the usable system of this asset as main interactuable for my project. I need to translate the names of the interactuable items (like doors, chests, and generally non actor names).

I know I can use a text table and use the key in the override field of the usable. But I was wondering if there's a way to make it work with the unity localization tables. Maybe making an item in the dialogue database (this way the name of the item appears in the unity localization tables).

If there´s currently a way to do it i'm not aware of it.

thanks in advance!
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localize usable overrides with Unity's localization

Post by Tony Li »

Hi,

Internally, the Usable component calls DialogueManager.GetLocalizedText() to look for a translation in the Text Table asset.

In the next release, I'll plan to update the Localization Package integration so it replaces DialogueManager.GetLocalizedText() with its own version that looks for a translation in the Localization Package's string tables.

In the meantime, or alternatively, you can make a subclass of Usable and override the GetName() method to pull translations from Unity's Localization Package.
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Re: Localize usable overrides with Unity's localization

Post by Pixelf0x3 »

Thanks for the quick response!

I that solution doesnt seem complicated, i will try.

The updates soud great, keep the good work.
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Re: Localize usable overrides with Unity's localization

Post by Pixelf0x3 »

I found another solution, if anyone is interested:

I made the Usable Override name in the Usables as an autoproperty

Code: Select all

[field: SerializeField] public string overrideName { get; set; }
this way I can attach a LocalizeStrignEvent that recognizes the override name as a dynamic string.

Same thing can be done with OverrideUseMessage.



The downside is that the inspector gets poluted with extra components. For each full translated usable = TWO LocalizeStringEvents.

Also, if the language is changed when the usable UI is active, it won't update the text untill you exit and re enter the trigger area.
Post Reply