Right to left language texts problem (Arabic, Persian)

Announcements, support questions, and discussion for the Dialogue System.
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Right to left language texts problem (Arabic, Persian)

Post by fanaei »

Hi
I'm using I2 Localiation + Dialogue System. The localization asset shows the RTL texts fine. But when I'm trying to use Dialogue system, it shows the letters seperated.
Please don't say that it's not your problem. Because a dialogue system is based on texts and it should fix such problems.

Thank you

(I searched the forum but I didn't find any answer.)
Amine33
Posts: 22
Joined: Mon May 21, 2018 4:48 pm

Re: Right to left language texts problem (Arabic, Persian)

Post by Amine33 »

The problem is not in dialogue system ..

The problem is in Unity because it does not support Arabic
I've been having the same problem but found a solution

Just enter this site.
(This is an example of how it works)
http://omar84.com/docs/taw/arabic_writer.html


Image


Image

Image
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Right to left language texts problem (Arabic, Persian)

Post by fanaei »

Yes, it's unity problem. But I2 localization plugin and many other assets fixed this problem in their codes.
I think it shouldn't be a big problem for the developers of this asset.
But if they don't fix it. I just wasted my money by buying it.
-------
About your solution:
I'm making an adventure game with lot's of dialogues and your solution is not suitable for me.
However there are some RTL plugins in asset store that can fix the rtl texts, but at first I need to find the string that shows the dialogues and then fix it by using rtl plugin. Can you show me that where can I find the variable that hold the dialogue texts?

If the developers can't fix the problem, at least they can give us some help and guidance.
User avatar
Tony Li
Posts: 20526
Joined: Thu Jul 18, 2013 1:27 pm

Re: Right to left language texts problem (Arabic, Persian)

Post by Tony Li »

Hi @fanaei - Please email your Unity Asset Store invoice number to tony (at) pixelcrushers.com. I'll be happy to refund you.

If you want to continue using the Dialogue System, here are things you can do:

1. To show the typewriter effect right-to-left, inspect the subtitle line text element, and tick Right To Left.

2. Use a font that connects letters. I recommend using TextMesh Pro because it has better right-to-left support than UI Text. It's free now, and the Dialogue System supports it natively.

3. If you want to do additional processing on your text, add a small script to the Dialogue Manager containing an OnConversationLine method. For example:
Spoiler

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class ProcessSubtitleText : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        subtitle.formattedText.text = /* process subtitle.formattedText.text however you want */
    }
}
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Right to left language texts problem (Arabic, Persian)

Post by fanaei »

Thank you Tony for your quick replay.
I used your 3rd solution + this code:
PersianFix.zip
(1.89 KiB) Downloaded 224 times
It's a free code and maybe you'll be able to use it in your next updates.

But I still have some problems, that you can see it in this shot:
DialogueSystemProblem1.jpg
DialogueSystemProblem1.jpg (228.25 KiB) Viewed 3718 times
The NPC dialogue is fixed now. But I still need to fix the text based on the language code and also change the direction. So how can I access those variables?
Also Player Dialogue still have problem and didn't get fixed.

Thanks again for your help.

(About (rtl) type writer effect, it shouldn't be based on the language? For example I'm using English and Arabic dialogues, so for English the effect shouldn't be Right to left. Also when I'm using it (+PersianFix code) the text start to type from the second line. Maybe it's because that the PersianFix uses a limit for letters per line.)

------------------------
Update:
I Fixed the NPC dialogue by I2 Localization codes, in this way:

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);
	}
}
And changed the direction:

Code: Select all

void Start () {
		if (I2.Loc.LocalizationManager.CurrentLanguageCode == "fa" || I2.Loc.LocalizationManager.CurrentLanguageCode == "ar") {
			GetComponent<Text> ().alignment = TextAnchor.MiddleRight;
		}
	}
But I think it's better to use another void instead of Start() . Do you have any suggestion?

I'm still searching for the variable or void to change the Player Answers.
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Right to left language texts problem (Arabic, Persian)

Post by fanaei »

Just fixed all of it by this below code.
But I got a new problem! Now the Player answer UI shows up so late! and dont know whay :(

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;

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);
		}
	}
}
User avatar
Tony Li
Posts: 20526
Joined: Thu Jul 18, 2013 1:27 pm

Re: Right to left language texts problem (Arabic, Persian)

Post by Tony Li »

Hi,

The NPC node waits for the duration of its Sequence. If its Sequence field is blank, it will use the Dialogue Manager's Default Sequence.

The Dialogue Manager's Default Sequence is initially set to: Delay({{end}})

This makes the node wait for a duration based on the length of the subtitle text. To reduce the duration, inspect the Dialogue Manager. Increase Subtitle Settings > Subtitle Chars Per Second, and decrease Min Subtitle Seconds. You may also need to increase the typewriter effect's Characters Per Second; otherwise the subtitle may disappear before the typewriter can finish.

If you don't want any delay at all, change the Dialogue Manager's Default Sequence to: None()

If you want each node to do something different, you can use other sequencer commands. For example, the demo scene's Default Sequence is AudioWait(entrytag). This plays a voiceover file. It also uses entrytags. You can localize Sequence fields and entrytags.

Thank you for your detailed notes on RTL. I'll incorporate these ideas into the next release.
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Right to left language texts problem (Arabic, Persian)

Post by fanaei »

New Problem!
If I hit the Continue button, the below code doesn't fix the rtl text

Code: Select all

	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);
		}
	}
User avatar
Tony Li
Posts: 20526
Joined: Thu Jul 18, 2013 1:27 pm

Re: Right to left language texts problem (Arabic, Persian)

Post by Tony Li »

Hi,

When you hit the Continue button, is the problem with the response menu button text or with the subtitle text?
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Right to left language texts problem (Arabic, Persian)

Post by fanaei »

The Responses have problem.
it seems OnConversationResponseMenu(Response[] responses) doesn't work.
Post Reply