Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Right-to-left (RTL) support (for languages such as Arabic and Hebrew) #3808

Open
talgalili opened this issue Nov 2, 2018 · 17 comments
Open

Comments

@talgalili
Copy link

@talgalili talgalili commented Nov 2, 2018

I'd love to be able to write rmarkdown text in Hebrew and have it rendered properly from right-to-left.
Here are some old requests regarding this:

And here is a relevant issue/PR on Ace that supposed to now make this feature available to also implement in RStudio: ajaxorg/ace#3400

Thanks.

@ronblum
Copy link
Contributor

@ronblum ronblum commented Nov 2, 2018

@talgalili תודה for the enhancement request. We'll take a look at it as we continue to develop new versions of RStudio.

@talgalili
Copy link
Author

@talgalili talgalili commented Nov 2, 2018

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Nov 6, 2018

My understanding is that RTL text support should be improving with the next version of Ace. Can you try out the version at #3820 and let us know if that does indeed appear to be the case? If so, then this is something we could potentially target for v1.3.

Note that you'll need to toggle the 'Rtl text' option in the options sidebar (it's 3rd from the bottom)

@m-hoseini
Copy link

@m-hoseini m-hoseini commented Nov 7, 2018

Same problem exists for Persian / Arabic text. Would be great if fixed.

@jmcphers jmcphers added the ace label Nov 13, 2018
@talgalili
Copy link
Author

@talgalili talgalili commented Jan 23, 2019

Hi @kevinushey , how can I test the version from #3820? (can you maybe send me an .exe url to try and install? and some suggestion on how to toggle the RTL in this version? Thanks!)

@Oravishayrizi
Copy link

@Oravishayrizi Oravishayrizi commented Jan 23, 2019

Hi,
I use <div text-align: right; dir="rtl"> to write in Hebrew, and for sentences that combine both languages I split the sentence into few rows, annoying but it works.

for example:
אני ארשום עברית ב-
R
ע"י כתיבת המילה באגנלית בצורה נפרדת.

@layik
Copy link

@layik layik commented Jul 6, 2019

I would also happily test anything/any version :)
There is partial support in the editor, definitely does not recognise RTL text, but it is worst in the viewer/plot area.
Rplot02

@layik
Copy link

@layik layik commented Jul 6, 2019

Also, would love to contribute if we get some "kick start" notes/pointers.

@ronblum
Copy link
Contributor

@ronblum ronblum commented Jul 10, 2019

@layik Thank you for the offer to help! If you’d like to work on this, we gladly accept pull requests. As a starting point, these instructions for building RStudio and testing pull requests locally provide guidance.

That said, support for RTL languages is available in the new version of Ace, so it’s something that we’ll take a look at as we’re working on new versions of RStudio. Information on this is available at https://ace.c9.io/build/kitchen-sink.html — try toggling the RTL option on the left.

@akarlinsky
Copy link

@akarlinsky akarlinsky commented Mar 15, 2020

Hi Ron, is this expected in the upcoming Rstudio 1.3?

@layik
Copy link

@layik layik commented Jun 7, 2020

Almost a year later I see your reply @ronblum. I think it was an upcoming trip that must have just made me forget it completely.

I can see in the open source components that ACE 2.1 is in the 1.3.9 version and though does not do auto switching to RTL the editor looks OK with RTL, but the viewer remains the same as above.

@cderv
Copy link
Collaborator

@cderv cderv commented Jan 5, 2021

A note about this after a question on twitter: new Visual Markdown Editor in 1.4 allows to get visually RTL block of text when writing an Rmd file.

Not hebrew here but the text is correctly written in RTL in the div with attributes dir=rtl. (Following Pandoc documentation on this) .
image

@mikebessuille
Copy link
Contributor

@mikebessuille mikebessuille commented Feb 18, 2021

Hadley requesting this...

@hadley
Copy link
Member

@hadley hadley commented Feb 18, 2021

Another issue display of RtL strings in data frames:

data.frame(id = 3L, string = "أباجور", r1 = "أ", r2 = "ب", r3 = "ا", r4 = "ج", r5 = "و", r6 = "ر")
#>   id string r1 r2 r3 r4 r5 r6
#> 1  3 أباجور  أ  ب  ا  ج  و  ر

Created on 2021-02-18 by the reprex package (v1.0.0)

Note that أباجور is in a column on the far left but is displayed on the right. I doubt this is solely the responsibility of the IDE, but it's probably involved. More discussion at tidyverse/tibble#433.

@layik
Copy link

@layik layik commented Feb 19, 2021

So good to have your attention @hadley. Indeed, the terminal is still not supporting RTL as one would have expected. Both Big Sur Terminal and RStudio 1.3.9 seems to be handling it the same. I changed the col names to see if it improves, but mixing 3L with RTL characters forces the "renderer" to separates 3&L. The output is slightly better. Right now Hyper 3.0.2 seems to be doing even worse, but there is a ticket.

Screenshot 2021-02-19 at 21 21 38

data.frame(ناو = 3L, دەق = "أباجور", ر١ = "أ", ر٢ = "ب", ر٣ = "ا", ر٤ = "ج", ر٥ = "و", ر٦ = "ر")
#>   ناو    دەق ر١ ر٢ ر٣ ر٤ ر٥ ر٦
#> 1   3 أباجور  أ  ب  ا  ج  و  ر

Created on 2021-02-19 by the reprex package (v0.3.0)

if we have everything as strings (""), things are slightly better (replace 3L with "لائق"):

data.frame(ناو = "لائق", دەق = "أباجور", ر١ = "أ", ر٢ = "ب", ر٣ = "ا", ر٤ = "ج", ر٥ = "و", ر٦ = "ر")
#>    ناو    دەق ر١ ر٢ ر٣ ر٤ ر٥ ر٦
#> 1 لائق أباجور  أ  ب  ا  ج  و  ر

Created on 2021-02-19 by the reprex package (v0.3.0)

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Feb 19, 2021

It would be worth testing whether this is handled better with the move to Electron. (I suspect it will, since we're effectively moving to a newer version of Chromium which should overall have better RTL support)

@krlmlr
Copy link
Contributor

@krlmlr krlmlr commented Apr 16, 2021

VS Code is getting @hadley's data frame example right without further intervention in R 4.0.5.

Screenshot from 2021-04-16 05-12-17

Maybe we can do what they do?

It's weird that the display looks correct, but as soon as the text is copied and pasted the direction flips again, like in the reprex:

data.frame(id = 3L, string = "أباجور", r1 = "أ", r2 = "ب", r3 = "ا", r4 = "ج", r5 = "و", r6 = "ر")
#>   id string r1 r2 r3 r4 r5 r6
#> 1  3 أباجور  أ  ب  ا  ج  و  ر

Created on 2021-04-16 by the reprex package (v1.0.0)

In tibble we can add LTR/RTL isolates to control the direction of the columns and also the direction of the text. These are picked up correctly by Linux terminals, by VS Code, and by pandoc -- not by RStudio 1.4.1103:

# Reference: https://www.w3.org/International/questions/qa-bidi-unicode-controls
fsi <- function(...) paste0("\u2068", ..., "\u2069")
lri <- function(...) paste0("\u2066", ..., "\u2069")
rli <- function(...) paste0("\u2067", ..., "\u2069")
lro <- function(...) paste0("\u202d", ..., "\u202c")

aleph <- "א"
bet <- "ב"

# Text output is right-to-left...
paste0(aleph, bet)
#> [1] "אב"

# but we can force the components to be left to right
writeLines(lro(paste0(
  fsi(aleph, bet),
  " ",
  fsi(bet, aleph)
)))
#> ‭⁨אב⁩ ⁨בא⁩‬

Created on 2021-04-16 by the reprex package (v1.0.0)

The example is from tidyverse/tibble#433 (comment).

@ronblum ronblum added the locale label Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet