Support-arabic

Support Arabic

Standalone script supports in-game Arabic entries.
GitHub Repository, Download

What is the issue in the first place ?

The game (or we could say RAGE) only supports the latin characters.
Which is used in English, Italian, etc… (there could be Japanese and Chinese letters supported, I haven’t searched enough tbh).
In case of Arabic characters “letters”, they are simply not supported, when you try to write in it, you just get that empty square which means unknown character, example:
Unknown Characters

Arabic Font

The “definer” of the Arabic characters which gives them the shape so you can read them.
You can use a font in your own (edit the manifest) but in case you don’t have an Arabic one…
There is an attached Arabic font in a streamable gfx format, credits: A9eelsh (there was no contact info to reach the provider, just found it in a public repository, so… it’s probably fine to use it).

Just adding the font fixes the problem ?

Unfortunately, no… Arabic characters are like any other language characters, except that writing in Arabic doesn’t mean to put the characters beside each other to form a word, there is a missing step to form a word.

What is missing ?

The characters must be linked to each other in a certain way, depending on their position in the word.
For example the character (ب) can be written in three different way depending on its position, which are:

  • At the beginning: (بـ)
  • At the middle: (ـبـ)
  • At the end: (ـب)

And of course… it’s not supported as well, so when you add an Arabic font and then you try to write in it, you will be able to, the characters will be there and you can still read the words, but it’s just uncomfortable for the players or any Arabic reader, which is the thing we try to avoid.
For example, notice how the sentence “مرحبا بك في مجتمعنا” (Welcome to our community) is written in-game:
Unlinked Arabic

So… that’s it ?

Well, Arabic language it self wasn’t that easy, right? There is another problem that needs to be mentioned. Which is that Arabic text direction is Right To Left aka RTL unlike most other languages that use the Left To Right direction aka LTR.
So even if you have the font and you decided somehow to ignore the linking between the characters, it would be still hard for the readers to read at their normal reading speed, as the characters will be reversed (the starting becomes the ending and vice-versa).
For example, to explain the above, try to read this: “e l b a t r o f m o c”, it doesn’t seem an English word at all, now… try to read it from right to left, you will notice that it’s just the word “comfortable” reversed, so if you know about the problem you can still read, but it’s missy and not that easy.

So far, what is the solution ?

With this script you can link and reverse the Arabic sentences to be readable, Notice the difference between the above and this:
Linked Arabic
Note: it’s obvious but anyway, this problem is with RAGE so there no need to use it with UI that involves HTML which supports Arabic.

Does that work in all cases ?

There is another problem. It happens when it comes to what I like to call a “hybrid string”.
A hybrid string is basically an array of characters, some of them are Arabic while some others are not.
Is that even an issue ? YES. Why is it an issue ? To answer that let’s see a live example.
A sentence (Arabic or Non-AR in direction) that player will be notified with:
test-sentence
First notification direction is LTR while the second one direction is RTL:
direction-difference
As you can see, the Arabic it self hasn’t affected, but the order of the sentences has reversed.
This could be fixed by typing سيرفر instead of Server and so on… which is taking the English vocal and type the parallel to it in Arabic (it’s not accepted linguistically but let’s say it is), however, there are some cases that you are forced to put a Non-Arabic word in a random position in a string, for example, the player name which is not always written in Arabic.
To fix that the string shall be redirected to suit LTR text direction system, which SupportArabic:redirect function does.

Functionality

The script works with exports so you can use it wherever you like.
Check the exported functions here if you want to use it in a specific way.
If you want to generally support Arabic in your resource, just add this line to its manifest:

client_script '@support-arabic/escaping.lua'

Note: support-arabic resource should be started before your resource.
You can take a look at this live example and it’s manifest for better understanding.

Issues

There is some hanging issues that need to be looked at.

Word Wrap

When ever there is a word-wrap, it won’t function properly.
For example, let’s notify the player with this sentence: مرحبا بك في مجتمعنا، إستمتع بوقتك (Welcome to our community, enjoy your time)
Wrap Arabic
Seems wrong right? Why is that? Well, word-wrap takes the last word (or two, or what suits the length) and put them in the start of the next line.
Remember that we just reversed the words, means that we made the first to be the last and vice-versa, That’s why it takes the first word instead of the last one.
The only solution is to find a replacement solution to remove the current “crack” solution, for now… test the sentences and type the line breaks manually, I’ll figure something out in the future, lmk if you have any ideas.

Multiline

Technically this is a subproblem of Word Wrap.
Since it LTR text direction system takes the last word, many words will eventually form a whole new line.
Which causes the first line to be the last and vice-versa.
TODO: provide example.

TODO

7 Likes

Nice :slight_smile:

1 Like

Dude this is awesome, and has been needed for so long.

Well done.

1 Like

can you make one for Greeks too ? :stuck_out_tongue:

Well, actually it took me some time to create such a script, so it’s going to be a while till I do another release, but I have good new.

First of all, I don’t know Greece that much, just heard of it since I’m using some of its letters (like Θθ, Φφ, Ψψ, Ωω, etc…) while studying math, physics or so… that’s why I need to say that my information about Greece comes from a quick search :sweat_smile:.

Anyways, Greece won’t face that much of problems that Arabic is facing, since it’s unlike Arabic, Greece text direction is LTR (left to right) which meets with the original game engine. In addition, Greece letters doesn’t have to be linked or reversed like Arabic, so that’s great, all you need is a font to add script to Greece characters unicode (support the language).

How would you do that? you need a streamable Greece font in gfx format.
How could you get it? tbh… idk, if there is no one, create it yourself.
How to do that? well, you need a swf version of the font which is easier to find, then you have to convert that version of the font swf to the gfx.
How to convert it? check out FiveM Docs it’s similar to the scaleform case.

2 Likes