[gen] Added support for right-to-left (RTL) languages.

This commit is contained in:
Gaetan Delannay 2012-06-27 13:27:24 +02:00
parent b680a5ddcb
commit 1b375d387c
18 changed files with 83 additions and 41 deletions

View file

@ -110,7 +110,7 @@ class ToolMixin(BaseMixin):
if not cfg.languageSelector: return
if len(cfg.languages) < 2: return
page = self.REQUEST.get('ACTUAL_URL').split('/')[-1]
return page not in ('edit', 'query', 'search')
return page not in ('edit', 'query', 'search', 'do')
def getLanguages(self):
'''Returns the supported languages. First one is the default.'''
@ -128,11 +128,21 @@ class ToolMixin(BaseMixin):
rq.RESPONSE.setCookie('_ZopeLg', rq['language'], path='/')
return self.goto(rq['HTTP_REFERER'])
def flipLanguageDirection(self, align, dir):
'''According to language direction p_dir ('ltr' or 'rtl'), this method
turns p_align from 'left' to 'right' (or the inverse) when
required.'''
if dir == 'ltr': return align
if align == 'left': return 'right'
if align == 'right': return 'left'
return align
def getGlobalCssJs(self):
'''Returns the list of CSS and JS files to include in the main template.
The method ensures that appy.css and appy.js come first.'''
names = self.getPhysicalRoot().ui.objectIds('File')
names.remove('appy.js'); names.insert(0, 'appy.js')
names.remove('appyrtl.css'); names.insert(0, 'appyrtl.css')
names.remove('appy.css'); names.insert(0, 'appy.css')
return names

View file

@ -10,6 +10,7 @@ from appy.gen.utils import *
from appy.gen.layout import Table, defaultPageLayouts
from appy.gen.descriptors import WorkflowDescriptor, ClassDescriptor
from appy.shared.utils import sequenceTypes
from appy.shared.data import rtlLanguages
# ------------------------------------------------------------------------------
class BaseMixin:
@ -1404,6 +1405,11 @@ class BaseMixin:
if '-' in res: res = res[:res.find('-')]
return res
def getLanguageDirection(self, lang):
'''Determines if p_lang is a LTR or RTL language.'''
if lang in rtlLanguages: return 'rtl'
return 'ltr'
def formatText(self, text, format='html'):
'''Produces a representation of p_text into the desired p_format, which
is "html" by default.'''