Forum Discussion

savasdenli's avatar
savasdenli
Reel Rookie
8 years ago

Right-to-left (RTL) Languages Support

Hi everyone. Now i am developing a Roku Channel with Arabic Language. Is there anyway of use Arabic language?

For now i'm using a StringReverse function to convert from ltr to rtl. And using an arabic font for letters shown correctly. It texts are not shown correctly.
For example "Comedy" must be shown as "كوميديا"
But it is shown like that "ك وم ي د يا" Without spaces but shown letter by letter inspite of words (In arabic when letters become to words they must be adjacent).
Note: In Youtube application there isn't this problem. Arabic words are shown correctly.

Thanks a lot.

11 Replies

  • 24i's avatar
    24i
    Streaming Star
    Hi savasdenli,

    Do you have any luck on solving this?
    We are currently developing an application that has to support Arabic languages and we are facing the same problem now.
    What do you do in the StringReverse function, as I take it it's something you created yourself?
  • "24i" wrote:
    Hi savasdenli,

    Do you have any luck on solving this?
    We are currently developing an application that has to support Arabic languages and we are facing the same problem now.
    What do you do in the StringReverse function, as I take it it's something you created yourself?

    I used this function but it is not enough. 
    function stringReverse(input as String) as String
       newStr = ""
       len = len(input)

       for i = len to 1 step -1
          newStr = newStr + mid(input, i, 1)
       end for

       return newStr
    end function
  • 24i's avatar
    24i
    Streaming Star
    Ah I see, thanks anyway!
    We made contact with Roku about this problem, they are looking into the problem with the engineering team. 
    Let's hope they can give us something to work with.
  • destruk's avatar
    destruk
    Streaming Star
    Without seeing the actual test display, source text and resulting full text, I can simply suggest - assuming that there is a space between each letter and two or three spaces between words now in the resulting produced output -
    A) run your routine as you have it now
    B) take the resulting returned string of arabic text and replace two or three consecutive spaces into an unused or uncommon character like *
    C) take the result of that operation and replace single spaces with nothing -- ie replace " " with ""
    D) take the result of that operation and replace your uncommon substituted character with a single space.

    It's a little more work, but if Roku fixes the original problem then you can remove this adjustment, and if they don't then you are good to go.

    If it is a display problem, you can check the length of the resulting string and compare it to the length of the source string.
    Print LEN(sourcetext)

    And for scenegraph, if the string lengths are the same you could put each character into it's own label field for display, and line up the labels with pixel accuracy for display overlapping them if needed to remove the gaps as required for manual display.

    Does the source string display with spaces between letters before you reverse the character order?
  • We gave up on the RTL support because we also went with the StringReverse alternative but it became a huge challenge when we had to support multiline labels. In case that is also a requirement in your channel, you should start considering how are you going to support it as soon as possible. I can share our attempts on that later if you need.
  • "destruk" wrote:
    Without seeing the actual test display, source text and resulting full text, I can simply suggest - assuming that there is a space between each letter and two or three spaces between words now in the resulting produced output -
    A) run your routine as you have it now
    B) take the resulting returned string of arabic text and replace two or three consecutive spaces into an unused or uncommon character like *
    C) take the result of that operation and replace single spaces with nothing -- ie replace " " with ""
    D) take the result of that operation and replace your uncommon substituted character with a single space.

    It's a little more work, but if Roku fixes the original problem then you can remove this adjustment, and if they don't then you are good to go.

    If it is a display problem, you can check the length of the resulting string and compare it to the length of the source string.
    Print LEN(sourcetext)

    And for scenegraph, if the string lengths are the same you could put each character into it's own label field for display, and line up the labels with pixel accuracy for display overlapping them if needed to remove the gaps as required for manual display.

    Does the source string display with spaces between letters before you reverse the character order?

    Thanks for your reply but the problem is not about spaces. If you look the letters in word "كو " when two letters written without spaces the form of letters must be change like this.

    "ك و " if you remove space between this two letter it must be like that  "كو ". In browser it has been automatically. But in roku it doesn't became.

    I want to help about this. Only in Youtube Channel this problem has not been occured and shown correctly.
  • 24i's avatar
    24i
    Streaming Star
    We gave up on RTL support as well (for now at least). 
    We had contact with Roku about this and currently those language are not supported and won't be supported in the near future. 
    As savasdenli said, it's not just about the spaces. Other problems you run into is having a keyboard that supports the characters, inputfields and subtitles to which you can't set a different font, rows not starting on the right, etc.
  • "rftvaa" wrote:
    We gave up on the RTL support because we also went with the StringReverse alternative but it became a huge challenge when we had to support multiline labels. In case that is also a requirement in your channel, you should start considering how are you going to support it as soon as possible. I can share our attempts on that later if you need.


    could you share what you did to solve this? Trying to support RTL on Roku for mutiline labels is becoming so frustrating. Anybody got any good solutions for this?
  • "govinds" wrote:
    "rftvaa" wrote:
    We gave up on the RTL support because we also went with the StringReverse alternative but it became a huge challenge when we had to support multiline labels. In case that is also a requirement in your channel, you should start considering how are you going to support it as soon as possible. I can share our attempts on that later if you need.


    could you share what you did to solve this? Trying to support RTL on Roku for mutiline labels is becoming so frustrating. Anybody got any good solutions for this?

    You said "good solution" so maybe this isn't that. "A solution" is to assume how many characters will fit a label regardless of screen real estate. Then assign 10 labels. Each of those labels number 1 through 10. Now each of those in itself is its own label its own line. You no longer do multi-line as you must now do this in a function using each of your 10 labels or however many you need do span lines onto. You may not need all 10 of these labels for your lines. They are there if you do. You would also have to deal with handling translation placements if this wasn't within say a layout group.

    Lets assume it is bound by a layout group that would handle align all the labels and eliminate needing any translation placements in the labels at all and still keep everything lined up nicely. You would probably need to write this as a component that extends the label node. Then use it to create a fake multi-line label using multiple labels. You reference it back by the layout group which would include the child nodes of the labels. Doing the math for all this to figure the right amount of characters to assume for the width of your labels would take some magic math equation. You might be able to use GetOneLineWidth() to more accurately tell when to chop the lines you feed to the labels and get pretty close to actually copy what multi-line labels do to begin with. You can't chop on bytes you have to chop on characters so hopefully the Roku can do this correctly using instr(index,$text," ") and index is the amount of characters you assume can fit the line if you can't get the GetOneLineWidth() to work with your custom fonts that work with any language such as Googles Noto. We could never make GetOneLineWidth() work reliably with right to left and string reverse. Maybe you can? Otherwise abandon it and instead count characters and assume a width-per-char to apply. You might always cut too soon but you can get it baby bear/goldilocks close. Where it is close enough for the government type of thing.

    But like others said the rows don't start on the right. Scrolling doesn't start on the right. You would have to roll-your-own components for all of these too that over-ride the default behavior. Extend the component and then customize it. There may be more shortcomings to this that I do not see as I have not fully attempted this yet. It is possible though but you must go through effort to get there. Roku does not make any of this easy when you work outside their supported language set. You go off the map so to speak and have to forge your own roads.

    It might also be possible to use a labellist and get the same effect as multiple labels without the limitation that wrap="true" imposes on labels? You need to try labellist and feed it cut lines as the list. This might also be possible and less math since you wouldn't need to track which label of the 10 to add data. You just append to the one labellist.

    function stringReverse(input as String) as String
       newStr = ""
       for each char in input.split("")
          newStr = char + newStr
       end for
       return newStr
    end function
  • Hi , 

    Did Roku solve the issue with Arabic Langauge as Interface and Search?

    Thanks 
    • OxymoronTech's avatar
      OxymoronTech
      Reel Rookie

      I had a same problem but with Hebrew. I'm not a Roku developer but I've needed to solve this anyway. And I pretty solved it but there is a few issues still there. It was really challenge for me because I came from OOP world of .Net/C#, NodeJS etc.

      Let's nail all challenges one by one:

      1. Letters appear in reverse order:
        • Solution: this is a simple part that you can fix with reverseString function
        • Problem: it works only for plain text, without any other symbols (see p.3)
      2. Multi-line text lines appear in reverse order:
        • Solution: I wrote BreakLines function that divides text in N lines (with whole words cuts). Than I used N labels instead of multi-text area. And filled them with lines.
        • Problem: the same as in p.1 - works only for plane texts. And also need to control long texts that labels not overlap another elements.
      3. Mixed text: That is a huuuuuge problem. There are a few subjects that should be addressed in RTL text processing:
      • numbers: they are always LTR, not need to reverse 
      • special symbols: it's a huge challenge when you have words delimiters like (), [], {}, dash and finally - quotes in any types (", ', `). You should count them as word delimiters like spaces but not always (single quote can be a part of word like "don't")
      • few languages together (like text in Hebrew and English name of company in the middle, or more complicated - name of song or product)

      All of this forced me to split my development between server and client (that is not really best practice, but I haven't a choice - BrightScript is a weak language with lack of basic functionality of strings processing and arrays manipulations Smiley Frustrated ). My solution was to divide text by language regions where is RTL or LTR direction and process them separately (server-side algorithm). Than this text come to client via API ready to display, except of multi-line appearance that is implemented in application. And after all of this - there are few annoying issues in UI still there 😕

      Now, guys, you understand why Roku don't support RTL 😄

      That was an interesting challenge for my 25-years development experience and I think I did my best to solve this not-trivial problem. I spent around 4 full days for this (with back and force with different approaches) but it was interesting 🙂