2
votes

I am using SilverStripe to build a website that should support both English (LTR) and Arabic (RTL) languages. In the templates I need to set the direction of the language.

<html lang="$ContentLocale" dir="$//SomethingHere//">

How can I detect the current language direction and provide that to the template?

1
Isn’t this already in SilverStrips default simple-theme? <% if $i18nScriptDirection %>dir="$i18nScriptDirection"<% end_if %> github.com/silverstripe-themes/silverstripe-simple/blob/master/… - munomono
thanks that did the trick ☺ - osama7901
plz mark 3dgoo's answer as correct, since it is. - munomono

1 Answers

4
votes

In SilverStripe 3.4 the i18n has a get_script_direction function that returns "rtl" or "ltr". This can be called through the template global variable $i18nScriptDirection.

<html lang="$ContentLocale" dir="$i18nScriptDirection">