Hey,
I have my own localization system that I have used in all projects that I have worked on. It basically loads in a file into a dictionary at runtime with a key and a string for that language. I do it this way because it lets translator use an external file, and easily test without needing access to unity.
I have written out conversations in English inside the dialogue system, I and for my writer I think I intend to keep doing it that way. And then regularly export the conversations for translations.
I exported it as a csv and the things called entrytag looks like a unique id.
So now my question, how would I go about dynamically loading from my dictionary instead of the "Dialogue text field", based on the entrytag.
Override dialogue text and actor names runtime only
-
- Posts: 10
- Joined: Wed Jun 14, 2023 10:33 am
Re: Override dialogue text and actor names runtime only
Hi,
Add a script with OnConversationLine(Subtitle) and OnConversationResponseMenu(Response[]) special script methods to the Dialogue Manager GameObject. Example:
Other Notes:
Add a script with OnConversationLine(Subtitle) and OnConversationResponseMenu(Response[]) special script methods to the Dialogue Manager GameObject. Example:
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
subtitle.formattedText = GetTranslation(subtitle.dialogueEntry);
}
void OnConversationResponseMenu(Response[] responses)
{
foreach (var response in responses)
{
response.formattedText = GetTranslation(response.destinationEntry);
}
}
string GetTranslation(DialogueEntry entry)
{
string entrytag = DialogueManager.masterDatabase.GetEntrytaglocal(entry.conversationID,
entry.id, DialogueManager.displaySettings.cameraSettings.entrytagFormat);
string translation = GET_TRANSLATION_FROM_YOUR_SYSTEM(entrytag);
return FormattedText.Parse(translation);
}
- The GetTranslation() example method above calls FormattedText.Parse() in case your translation has any special markup tags to process.
- If you don't want to manage your own CSV export/import, you can export localization CSV files from the Dialogue Editor's Database > Export/Import Localization section.
- In version 2.2.48 (which I expect to be available on the Asset Store tomorrow), you can also import those localization CSV files at runtime. So your translator can drop the translated CSV files into a directory, and you can write a line of code to import it into your game.
-
- Posts: 10
- Joined: Wed Jun 14, 2023 10:33 am
Re: Override dialogue text and actor names runtime only
Seems to work, nice and easy, had to do some slight alternations jsut in case sommeone else stummble into this
As a follow up is ther anyway to manually export the data from the database with my own formatting, its a bit of copy paste job right now. When using the default CSV exporter
Code: Select all
void OnConversationLine(Subtitle subtitle) {
subtitle.formattedText = GetTranslation(subtitle.dialogueEntry);
}
void OnConversationResponseMenu(Response[] responses) {
foreach (var response in responses) {
response.formattedText = GetTranslation(response.destinationEntry);
}
}
FormattedText GetTranslation(DialogueEntry entry) {
string entrytag = DialogueManager.masterDatabase.GetEntrytag(entry.conversationID,
entry.id, EntrytagFormat.ActorName_ConversationID_EntryID);
Debug.Log(entrytag);
string translation = GameDataHolder.Instance.localizationData.localization[entrytag];
return FormattedText.Parse(translation);
}
Re: Override dialogue text and actor names runtime only
Hi,
You could write your own exporter in a separate editor script/window of your own.
Or use the Dialogue Editor's Database > Localization Export/Import to export it to CSV.
Version 2.2.48 also has a new proofreading text format that looks like this:
if that would be any help.
You could write your own exporter in a separate editor script/window of your own.
Or use the Dialogue Editor's Database > Localization Export/Import to export it to CSV.
Version 2.2.48 also has a new proofreading text format that looks like this:
Code: Select all
|> Proofreading File for Demo Database
|> Do not modify lines that start with '|>'!
|>
|> ACTORS -------------------------------------------------
|> ACTOR [1]: Player
|> DESCRIPTION:
The Player controls a soldier sent to intercept the evil space emperor's launch codes to prevent him from attacking your planet.
|>
|> ACTOR [2]: Private Hart
|> DESCRIPTION:
Private Hart is a kind-hearted soldier who offers the quest to hack the emperor's computer to get the launch codes.
|>
...
|> CONVERSATIONS ------------------------------------------
|> CONVERSATION [1]: Private Hart
|> DESCRIPTION:
This conversation occurs between the Player and Private Hart, who explains the main quest (Get the Launch Codes). Nodes' Conditions fields branch the conversation based on the current quest state.
|> ENTRY [1] (Private Hart)
|> DIALOGUE TEXT:
We need to intercept the launch codes before the enemy launches their weapon at our home world.
...