Really vague localization question

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Really vague localization question

Post by nathanj »

Hi Tony

We're starting to think about expanding our game to feature custom localization for each build. I imagine it would be a set of variables something like ["Firewood"] which would be replaced with local language. To adapt this for multiple projects with many languages we would create separate variable databases and then merge those into the main system when building.

I imagine that the above will work as expected, my question is: is it possible to feed the text of another system, such as uSurvival, into Dialogue System's UI so that, if a sting such as ["Firewood"] were present, it could be converted?

Thanks in advance,

Last update was :D :D :D

Nathan
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Really vague localization question

Post by Tony Li »

You can localize everything in the Dialogue System. I'm guessing that Variable["Firewood"] is a number representing the amount of firewood the player has collected. Let's say you have a quest named "Get Firewood" with these fields:
  • Name: "Get Firewood"
  • Description: "Search the area for enough wood to build a fire."
  • Entry 1: "[var=Firewood]/3 Collected"
To localize to French, add these fields (Type = Localization):
  • Name: "Get Firewood"
  • Display Name: "Get Firewood"
  • Display Name fr: "Obtenez du bois de chauffage"
  • Description: "Search the area for enough wood to build a fire."
  • Description fr: "Cherchez suffisamment de bois dans la région pour faire un feu."
  • Entry 1: "[var=Firewood]/3 Collected"
  • Entry 1 fr: "[var=Firewood]/3 Obtenu"
You can find more details on the Localization page.

There are two types of non-Dialogue System text to localize. You can use Text Tables for both:

1. UI elements (e.g., the Login button). See Using Text Tables to Localize UIs.

2. Other text. Assuming the text has a localize entry in your text table, just call DialogueManager.GetLocalizedText("your text") to get the localized version from the text table, or use the corresponding visual scripting action.
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Really vague localization question

Post by nathanj »

Thanks Tony,

I'm only looking to replace nouns and verbs, not all text, so Loclization is more than what we need.

I'm hoping for something like the Localize UI but that dynamically updates, so it would behave similar to the Alert panel. In fact, if there were a way to have all UI text display the same way the Alert Panel does all my needs would be served. Is this possible? I'm guessing it might be an inefficient way of doing things.

I'm still thinking that using a variable system to replace text will still be the most efficient way to do this (I do love to be proved wrong if I'm on the wrong path though). So rather than assigning a numerical value to "Firewood" its 'Initial Value' would be its translated text "djarraba". Using a Text Table would be a lot cleaner but a collection of variables isn't terrible.

Because we aim to do this for numerous communities, each with its own unique language, I'm thinking that each project would have its own variable database that would be merged with the main database to allow for the localisation.

The biggest challenge with the method I described above (as this already works entirely in DS) is having Unity UI displaying the LUA variable's 'Initial Value'; is this possible? Is there a way to send, say, the UI content of uSurvival through a Dialogue Manager so that if the item was labelled "[var=Firewood]" it could replace the string "[var=Firewood]" with "djarraba" when displayed in the UI?

Does this sound like a workable method to you?

I hope this isn't too far out of the scope of DS.

Thanks once again,
Nathan
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Really vague localization question

Post by Tony Li »

Hi Nathan,

What kind of UI text are you thinking of? The LocalizeUI component is for design-time text, such as the word "QUIT" on uSurvival's Quit button. This pulls translations from a text table.

If you're talking about, say, the interaction text that appears when you mouse over an item or a door, uSurvival produces that at runtime. Fortunately, it's pretty easy to add localization. I'll explain how to localize the door interaction text, but the same process applies to items.

Make a copy of Door.cs. Rename is something like Door2.cs or DoorLocalized.cs. Edit it and rename the class accordingly. Change the GetInteractionText() method from this:

Code: Select all

public string GetInteractionText()
{
    return (open ? "Close" : "Open") + " door";
}
to something like this:

Code: Select all

public string GetInteractionText()
{
    return PixelCrushers.DialogueSystem.GetLocalizedText((open ? "Close" : "Open") + " door");
}
Then add two entries to your text table:
  • "Open door"
  • "Close door"
Or, if you want to process [var=varName] tags instead of using a text table, set GetInteractionText() to this:

Code: Select all

public string GetInteractionText()
{
    return PixelCrushers.DialogueSystem.FormattedText.ParseCode((open ? "Close" : "Open") + " [var=door]");
}
You'll need to use this script in place of Door in your project. You could always directly edit Door.cs, but then you'll need to remember to re-add those edits if you ever update uSurvival.
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Really vague localization question

Post by nathanj »

Thanks, Tony!

This is great. I’m out of the office for the weekend but will try this in a few days.

One more question. Can the Dialogue and Quest UI display Text Table content the same way that the Alert panel does? It tried setting this up yesterday but didn’t have any success.

Thank you,
Nathan
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Really vague localization question

Post by Tony Li »

Hi Nathan,

UI elements like the dialogue UI's Continue button and the Quest Log Window's Close button can use the Text Table. The Quest Log Window's default "No active quests" and "No completed quests" content can also use the Text Table.

Conversations and quest descriptions themselves don't use text tables. They use the localization that's inside the dialogue database.
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Really vague localization question

Post by nathanj »

Thanks Tony

Finally got my head around this.

Thanks for your patience.

Nathan
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: Really vague localization question

Post by Tony Li »

No worries! Localization is a bit piecemeal, being spread across text tables and dialogue databases, but I swear there's a logic to it. ;-)
User avatar
nathanj
Posts: 303
Joined: Sat May 28, 2016 12:30 am

Re: Really vague localization question

Post by nathanj »

Ya, I can see the logic to it and it makes complete sense for using it the way it’s intended. I’m just trying to make it do something a bit different. Luckily Dialogue System once again proves to be robust enough to make obscure requests possible with relative ease.

Nathan
Post Reply