Right to left language texts problem (Arabic, Persian)
Re: Right to left language texts problem (Arabic, Persian)
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)
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?
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)
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.
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)
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:
It seems there's a timing that ruin everything.
This is shot from unity, maybe it helps:
Re: Right to left language texts problem (Arabic, Persian)
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
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?
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
Spoiler
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);
}
}
}
}
Can you point out any differences from your scene that could be causing the issue?
Re: Right to left language texts problem (Arabic, Persian)
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.
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.
Re: Right to left language texts problem (Arabic, Persian)
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)
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.
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)
Hi,
Please download and import these packages:
Please download and import these packages:
- DialogueSystem_ConversationViewPatch_2018-08-17.unitypackage: Fixes the continue button issue.
- I2Localization_Support_2018-08-17.unitypackage: Adds a new component "Dialogue System Use I2 RTL Fix". Add it to your Dialogue Manager.
- TestRTL_2018-08-17.unitypackage: Example scene that uses both packages above.
Re: Right to left language texts problem (Arabic, Persian)
Wow! Thank you soooooo much Tony. Now it works fine.