Shinydashboards from right to left (localizing a shinydashboard to Hebrew)

Post by Adi Sarid (Sarid Institute for Research Services LTD.)

Lately I’ve been working a lot with the shinydashboard library.
Like shiny, it allows any R programmer to harness the power of R and create professional looking interactive apps. The thing about shinydashboards is that it makes wonderfully looking dashboards.

What I’ve been doing with the dashboards is to create dedicated dashboards for my customers. Since most of my customers speak, read, and write in Hebrew I needed to fit that into my shinydashboard apps (i.e., fully localize the app). See an example for such a localized dashboard I made here.

Making a shinydashboard localized turned out to be simpler than I thought. 

Since the average R programmer doesn’t necessarily know and understand CSS, I thought I post my solution. This should fit any Hebrew or Arabic dashboard to work from right to left, including the sidebar and all other objects (though I only tested it in Hebrew).

If you want the short version:
(1) Download the following css file;
(2) Put it in a subfolder “/www” of your shinydashboard app;
(3) In your dashboardBody command (within the ui.R section of your shiny app) add the following code:
[code]]czoxMzQ6XCJkYXNoYm9hcmRCb2R5KDxiciAvPgogICB0YWdzJGhlYWQoPGJyIC8+CiAgICAgIHRhZ3MkbGluayhyZWwgPSBcInN0eWxle1smKiZdfXNoZWV0XCIsIHR5cGUgPSBcInRleHQvY3NzXCIsIGhyZWYgPSBcImJvb3RzdHJhcC1ydGwuY3NzXCI8YnIgLz4KKSwuLi5cIjt7WyYqJl19[[/code]


Here are the few insights and steps which lead me to this solution:

Insight #1:
any shiny app (dashboard or otherwise) can be customized using CSS. That’s no secret. However, the adaptation to RTL isn’t that simple when you have so many objects, mobile responsiveness to worry about, etc.

Insight #2:
Shiny is based on the AdminLTE theme which is based on the bootstrap 3 theme. AdminLTE is a great theme, and even though it doesn’t officially support RTL, mmdsharifi, provided a solution in his github page. The same for bootstrap 3 which has an RTL customization by morteza (also on github).

Insight #3:
 What I did in order to make this work was to take the bootstrap-rtl.css from morteza, and then concatenate the AdminLTE-rtl.css file by mmdsharifi. Voilà! (simple, isn’t it?)

Here’s the resulting css file.

Thanks to 0xOri for suggesting and testing insight #3.





Published by

Adi Sarid

Adi is a partner and head of Operations Research department at the Sarid Research Institute and also a PhD student at the department of industrial engineering at Tel-Aviv university. He completed his MSc in the department of statistics and operations research in Tel-Aviv university, and BA in mathematics, statistics and operations research in the Israel Institute for Technology (Technion) in Haifa.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.