def add_direction(value, arg=u"<STR_LIT>"):
if arg == u'<STR_LIT>':<EOL><INDENT>directions = (u'<STR_LIT>', u'<STR_LIT>')<EOL><DEDENT>elif arg == u'<STR_LIT>':<EOL><INDENT>directions = (u'<STR_LIT>', u'<STR_LIT>')<EOL><DEDENT>elif arg == u'<STR_LIT>':<EOL><INDENT>directions = (u'<STR_LIT>', u'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise template.TemplateSyntaxError('<STR_LIT>')<EOL><DEDENT>parts = value.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL>if not len(parts):<EOL><INDENT>return value<EOL><DEDENT>elif len(parts) == <NUM_LIT:1>:<EOL><INDENT>return value + directions[translation.get_language_bidi()]<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT:.>'.join((parts[<NUM_LIT:0>]+directions[translation.get_language_bidi()],parts[<NUM_LIT:1>]))<EOL><DEDENT>
Adds direction to the element

    :arguments:
        arg
            * rtl_only: Add the direction only in case of a
              right-to-left language (default)
            * both: add the direction in both case
            * ltr_only: Add the direction only in case of a
              left-to-right language

    {{image_name|add_direction}} when image_name is 'start_arrow.png'
    results in 'start_arrow_rtl.png' in case of RTL language, and
    'start_arrow.png' or 'start_arrow_ltr.png' depends on `arg` value.