diff MoinMoin/formatter/text_html.py @ 401:61e50f3aaf68

fix projection CSS, fix win32 request init, revert Florian's langAttr fix (already done in refactor branch) imported from: moin--main--1.5--patch-405
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 27 Jan 2006 18:47:39 +0000
parents 7ce195b2189a
children bea43f99cc27
line wrap: on
line diff
--- a/MoinMoin/formatter/text_html.py	Thu Jan 26 22:39:22 2006 +0000
+++ b/MoinMoin/formatter/text_html.py	Fri Jan 27 18:47:39 2006 +0000
@@ -49,6 +49,27 @@
     # code clean and handle pathological cases like unclosed p and
     # inline tags.
 
+    def langAttr(self, lang=None):
+        """ Return lang and dir attribute
+
+        Must be used on all block elements - div, p, table, etc.
+        @param lang: if defined, will return attributes for lang. if not
+            defined, will return attributes only if the current lang is
+            different from the content lang.
+        @rtype: dict
+        @retrun: language attributes
+        """
+        if not lang:
+            lang = self.request.current_lang
+            # Actions that generate content in user language should change
+            # the content lang from the default defined in cfg.
+            if lang == self.request.content_lang:
+                # lang is inherited from content div
+                return {}
+
+        attr = {'lang': lang, 'dir': i18n.getDirection(lang),}
+        return attr
+
     def formatAttributes(self, attr=None):
         """ Return formatted attributes string