@jingo.register.filter
def locale_html(translatedfield):
 if (not translatedfield):
  return ''
 site_locale = translation.to_locale(translation.get_language())
 locale = translation.to_locale(translatedfield.locale)
 if (locale == site_locale):
  return ''
 else:
  rtl_locales = map(translation.to_locale, settings.RTL_LANGUAGES)
  textdir = ('rtl' if (locale in rtl_locales) else 'ltr')
  return jinja2.Markup((' lang="%s" dir="%s"' % (jinja2.escape(translatedfield.locale), textdir)))

@ jingo . register . filter def locale_html ( translatedfield ) : if ( not translatedfield ) : return '' site_locale = translation . to_locale ( translation . get_language ( ) ) locale = translation . to_locale ( translatedfield . locale ) if ( locale == site_locale ) : return '' else : rtl_locales = map ( translation . to_locale , settings . RTL_LANGUAGES ) textdir = ( 'rtl' if ( locale in rtl_locales ) else 'ltr' ) return jinja2 . Markup ( ( ' lang="%s" dir="%s"' % ( jinja2 . escape ( translatedfield . locale ) , textdir ) ) )
html attributes for languages different than the site language .