Page 2 of 3
Re: Right to left language texts problem (Arabic, Persian)
Posted: Thu Aug 16, 2018 2:07 pm
by Tony Li
Is the script containing OnConversationResponseMenu on the Dialogue Manager? OnConversationResponseMenu is only invoked on the Dialogue Manager and its children, not on the conversation participants.
Re: Right to left language texts problem (Arabic, Persian)
Posted: Thu Aug 16, 2018 2:28 pm
by fanaei
As you said before, I made the below code and attached it to Dialogue Manager.
It fixes everything, But when I use continue button, the texts in response menu don't get fixed.
So how can I access the responses texts and fix them before showing a response menu?
Code: Select all
public class FixFarsi : MonoBehaviour {
public int TextLimit = 999;
void OnConversationLine(Subtitle subtitle)
{
subtitle.formattedText.text = I2.Loc.LocalizationManager.ApplyRTLfix (subtitle.formattedText.text, TextLimit, false);
}
void OnConversationResponseMenu(Response[] responses)
{
for (int i = 0; i < responses.Length; i++) {
responses [i].formattedText.text = I2.Loc.LocalizationManager.ApplyRTLfix (responses [i].formattedText.text, TextLimit, false);
}
}
}
Re: Right to left language texts problem (Arabic, Persian)
Posted: Thu Aug 16, 2018 3:00 pm
by Tony Li
When the continue button is clicked, it calls OnConversationResponseMenu twice. This isn't technically necessary, and it appears to cause problems with I2.Loc.LocalizationManager.ApplyTRLfix. You're probably getting this error message:
IndexOutOfRangeException: Array index is out of range.
I2.Loc.LocalizationManager.ApplyRTLfix (System.String line, Int32 maxCharacters, Boolean ignoreNumbers) (at Assets/I2/Localization/Scripts/Manager/LocalizationManager_RTL.cs:53)
I'll post a fix by the end of the day.
Re: Right to left language texts problem (Arabic, Persian)
Posted: Thu Aug 16, 2018 3:45 pm
by fanaei
I don't get any error. Also if I wait for about 4-5 seconds and then hit the continue button, the responses are OK!
It seems there's a timing that ruin everything.
This is shot from unity, maybe it helps:

- DialogueSystemProblem2.jpg (119.72 KiB) Viewed 3511 times
Re: Right to left language texts problem (Arabic, Persian)
Posted: Thu Aug 16, 2018 6:22 pm
by Tony Li
Hi,
I haven't been able to reproduce the problem. This is the test scene that I'm using:
TestRTL_2018-08-16.unitypackage
It uses this script:
TestFarsi.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class TestFarsi : MonoBehaviour
{
public bool useFarsi = true;
public int TextLimit = 999;
private void Start()
{
if (useFarsi)
{
Debug.Log("Setting language to Persian [fa]");
I2.Loc.LocalizationManager.SetLanguageAndCode("Persian", "fa");
}
var useI2 = GetComponent<PixelCrushers.DialogueSystem.I2Support.DialogueSystemUseI2Language>();
if (useI2 != null) useI2.UseCurrentI2Language();
}
private bool IsRTL()
{
// For some reason I2 doesn't treat "fa" as RTL. This method does:
return I2.Loc.LocalizationManager.IsRight2Left || I2.Loc.LocalizationManager.CurrentLanguageCode == "fa";
}
void OnConversationStart(Transform actor)
{
var ui = DialogueManager.dialogueUI as StandardDialogueUI;
if (ui != null)
{
foreach (var subtitlePanel in ui.conversationUIElements.subtitlePanels)
{
if (subtitlePanel != null)
{
if (subtitlePanel.subtitleText.uiText != null)
{
subtitlePanel.subtitleText.uiText.alignment = IsRTL() ? TextAnchor.UpperRight : TextAnchor.UpperLeft;
}
#if TMP_PRESENT
// TO DO: Set subtitlePanel.subtitleText.textMeshProUGUI alignment.
#endif
var typewriter = subtitlePanel.GetTypewriter();
if (typewriter == null) Debug.Log("Can't find tw on " + subtitlePanel, subtitlePanel);
if (typewriter != null)
{
typewriter.rightToLeft = IsRTL();
}
}
}
}
}
void OnConversationLine(Subtitle subtitle)
{
if (IsRTL())
{
subtitle.formattedText.text = I2.Loc.LocalizationManager.ApplyRTLfix(subtitle.formattedText.text, TextLimit, false);
}
}
void OnConversationResponseMenu(Response[] responses)
{
if (IsRTL())
{
for (int i = 0; i < responses.Length; i++)
{
responses[i].formattedText.text = I2.Loc.LocalizationManager.ApplyRTLfix(responses[i].formattedText.text, TextLimit, false);
}
}
}
}
I will implement a more formal solution in version 2.0.4.
Can you point out any differences from your scene that could be causing the issue?
Re: Right to left language texts problem (Arabic, Persian)
Posted: Fri Aug 17, 2018 7:16 am
by fanaei
I used your Scene and code, but it still has problem.
If I hit the continue button immediately, it shows the letters of answer in a wrong way. But if I wait for about 3 seconds and then click on continue, the texts are fine.

- DialogueSystemProblem3.jpg (38.98 KiB) Viewed 3503 times
Re: Right to left language texts problem (Arabic, Persian)
Posted: Fri Aug 17, 2018 9:07 am
by Tony Li
Thank you for the screenshot. I'll investigate this right now. Sorry for taking so long to resolve this. I don't know Farsi or Arabic, so I must look pretty ignorant by not recognizing when text is completely backward.

Re: Right to left language texts problem (Arabic, Persian)
Posted: Fri Aug 17, 2018 9:51 am
by fanaei
Yeah, I understand that it's hard for you.
For making it easier, just use a simple word like this one:
تست
If the letters were connected like here, so everything is okay.
Re: Right to left language texts problem (Arabic, Persian)
Posted: Fri Aug 17, 2018 10:29 am
by Tony Li
Hi,
Please download and import these packages:
I think they should work correctly.
Re: Right to left language texts problem (Arabic, Persian)
Posted: Fri Aug 17, 2018 11:57 am
by fanaei
Wow! Thank you soooooo much Tony. Now it works fine.