Repository: getnikola/nikola

Issue:
RTL support in base theme
Need to set `dir="rtl"` on `<html>` for all RTL documents. Based on document language for list for RTL languages.

Default theme’s stylesheet need to mirror UI (float: left becomes right, margin-left becomes margin-right, arrow change direction and before becomes after) based on `:dir(rtl)` selector (Firefox only, CSS4 futuristic awesomeness).



Discussion:
If you set that up to a variable we could just do it globally.

> Default theme’s stylesheet need to mirror UI (float: left becomes right, margin-left becomes margin-right, arrow change direction and before becomes after) based on :dir(rtl) selector (Firefox only, CSS4 futuristic awesomeness).

This is fixed through #1137.

> Need to set `dir="rtl"` on `<html>` for all RTL documents. Based on document language for list for RTL languages.

This remains.

So, we need to create a mapping that says, for example (based on our current locales):

``` python
RTL_LANGUAGES = ('fa', 'ur')
```

(possibly in the `LEGAL_VALUES` dict in nikola.py)

and, in our templates (skipping the rest of that mess):

``` mako
<html
% if lang in RTL_LANGUAGES:
    dir="rtl"
% endif
>
```

Anything else to do?

@Kwpolska, that's it. It will put browsers in RTL mode and they should sort out stuff like picking a capable font on their own.

The stylesheet stuff will start working in Firefox soon, and the other browsers will follow. `::dir(rtl)` is from CSS4. Making something that works in today’s browsers is a lot more work and way less maintainable. However, the base theme looks totally fine even without the RTL specific mirroring tweaks.

An actual RTL user may have more requirements, but this covers the basics.

On Fri, Mar 28, 2014 at 09:18:19AM -0700, Daniel Aleksandersen wrote:

> @Kwpolska, that's it. It will put browsers in RTL mode and they should sort out stuff like picking a capable font on their own.
> 
> The stylesheet stuff will start working in Firefox soon, and the other browsers will follow. `::dir(rtl)` is from CSS4. Making something that works in today’s browsers is a lot more work and way less maintainable. However, the base theme looks totally fine even without the RTL specific mirroring tweaks.

I was testing the new stylesheet (with `<html dir="rtl">` under Chrome 35 (dev).  It looked well.  Is it (a) because it’s good enough today, or (b) because it already works in Chrome 35?

## 

Chris “Kwpolska” Warrick http://kwpolska.tk
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense


Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -120,6 +120,7 @@
         'ur': 'Urdu',
         'zh_cn': 'Chinese (Simplified)',
     },
+    'RTL_LANGUAGES': ('fa', 'ur'),
 }
 
 
@@ -663,6 +664,7 @@ def render_template(self, template_name, output_name, context):
         local_context.update(context)
         for k in self._GLOBAL_CONTEXT_TRANSLATABLE:
             local_context[k] = local_context[k](local_context['lang'])
+        local_context['is_rtl'] = local_context['lang'] in LEGAL_VALUES['RTL_LANGUAGES']
         # string, arguments
         local_context["formatmsg"] = lambda s, *a: s % a
         data = self.template_system.render_template(


Test patch: