<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,6 +25,7 @@ from django.utils.functional import lazy
 
 from pootle_app.models.translation_project import TranslationProject
 from pootle_app.models.language import Language
+from pootle.i18n.util import language_dir
 
 # START BOOTSTRAPPING TRANSLATION CODE
 
@@ -77,7 +78,7 @@ class DummyTranslation(object):
 #    return DummyTranslation()
 
 # Must be replaced after the bootstrapping phase by a function that returns
-# and actual pootle Project object for the language code.
+# an actual pootle Project object for the language code.
 def check_for_language(language):
     try:
         return TranslationProject.objects.get(language=language, project__code='pootle')
@@ -178,6 +179,19 @@ def ngettext(singular, plural, number, vars=None):
 def ungettext(singular, plural, number, vars=None):
     return _format_gettext(as_unicode(get_translation().ungettext(singular, plural, number)), vars)
 
+def get_language():
+    &quot;&quot;&quot;A function in the translation module to be used in the templates with
+        get_current_language as LANGUAGE_CODE
+    Since we hijack everything else, we have to hijack this as well.&quot;&quot;&quot;
+    return _active_translations[currentThread()].language.code
+
+def get_language_bidi():
+    &quot;&quot;&quot;A stupidly named Django function to indicate if the current language is
+    RTL. We have to hijack it, but just as well, since their implimentation
+    covers far less languages than we do.&quot;&quot;&quot;
+    base_lang = get_language().split('-')[0]
+    return language_dir(base_lang) == &quot;rtl&quot;
+
 def hijack_django_translation_functions():
     # Here is where we hijack the Django localization functions.
     # These lines are crucial, since they ensure that all translation
@@ -192,6 +206,9 @@ def hijack_django_translation_functions():
     translation.ugettext_lazy  = lazy(ugettext, unicode)
     translation.ungettext_lazy = lazy(ungettext, unicode)
 
+    translation.get_language = get_language
+    translation.get_language_bidi = get_language_bidi
+
 hijack_django_translation_functions()
 
 </diff>
      <filename>pootle/i18n/gettext.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a5e0a88c5983ab844b872755e7f4e8f0f7e3e091</id>
    </parent>
  </parents>
  <author>
    <name>friedelwolff</name>
    <email>friedelwolff@54714841-351b-0410-a198-e36a94b762f5</email>
  </author>
  <url>http://github.com/translateorgza/pootle/commit/8f2ce2847b36f7d0d4b2cfe8de67238ed0e41234</url>
  <id>8f2ce2847b36f7d0d4b2cfe8de67238ed0e41234</id>
  <committed-date>2009-06-02T13:18:07-07:00</committed-date>
  <authored-date>2009-06-02T13:18:07-07:00</authored-date>
  <message>Also hijack the functions get_language() and get_language_bidi() required by Django template_tags. This way we have the correct lang= and dir= attributes available in the Django templates.

git-svn-id: https://translate.svn.sourceforge.net/svnroot/translate/src/trunk/Pootle@11283 54714841-351b-0410-a198-e36a94b762f5</message>
  <tree>960e406ffd6a538d50caf4a593bab17496322a6a</tree>
  <committer>
    <name>friedelwolff</name>
    <email>friedelwolff@54714841-351b-0410-a198-e36a94b762f5</email>
  </committer>
</commit>
