Ticket #1660: django_bidi.diff
File django_bidi.diff, 3.1 KB (added by , 19 years ago) |
---|
-
django/conf/global_settings.py
62 62 ('zh-tw', _('Traditional Chinese')), 63 63 ) 64 64 65 # Languages using BiDi (right-to-left) layout 66 LANGUAGES_BIDI = ("he",) 67 65 68 # Not-necessarily-technical managers of the site. They get broken link 66 69 # notifications and other various e-mails. 67 70 MANAGERS = ADMINS -
django/templatetags/i18n.py
23 23 context[self.variable] = translation.get_language() 24 24 return '' 25 25 26 class GetCurrentLanguageBidiNode(Node): 27 def __init__(self, variable): 28 self.variable = variable 29 30 def render(self, context): 31 context[self.variable] = translation.get_language_bidi() 32 return '' 33 26 34 class TranslateNode(Node): 27 35 def __init__(self, value, noop): 28 36 self.value = value … … 102 110 """ 103 111 args = token.contents.split() 104 112 if len(args) != 3 or args[1] != 'as': 105 raise TemplateSyntaxError, "'get_ available_languages' requires 'as variable' (got %r)" % args113 raise TemplateSyntaxError, "'get_current_language' requires 'as variable' (got %r)" % args 106 114 return GetCurrentLanguageNode(args[2]) 107 115 116 def do_get_current_language_bidi(parser, token): 117 """ 118 This will store the current language layout in the context. 119 120 Usage:: 121 122 {% get_current_language_bidi as bidi %} 123 124 This will fetch the currently active language's layout and 125 put it's value into the ``bidi`` context variable. 126 True indicates right-to-left layout, otherwise left-to-right 127 """ 128 args = token.contents.split() 129 if len(args) != 3 or args[1] != 'as': 130 raise TemplateSyntaxError, "'get_current_language_bidi' requires 'as variable' (got %r)" % args 131 return GetCurrentLanguageBidiNode(args[2]) 132 108 133 def do_translate(parser, token): 109 134 """ 110 135 This will mark a string for translation and will … … 217 242 218 243 register.tag('get_available_languages', do_get_available_languages) 219 244 register.tag('get_current_language', do_get_current_language) 245 register.tag('get_current_language_bidi', do_get_current_language_bidi) 220 246 register.tag('trans', do_translate) 221 247 register.tag('blocktrans', do_block_translate) -
django/utils/translation.py
212 212 from django.conf import settings 213 213 return settings.LANGUAGE_CODE 214 214 215 def get_language_bidi(): 216 """ 217 Returns selected language's BiDi layout. 218 False = left-to-right layout 219 True = right-to-left layout 220 """ 221 222 from django.conf import settings 223 return get_language() in settings.LANGUAGES_BIDI 224 215 225 def catalog(): 216 226 """ 217 227 This function returns the current active catalog for further processing.