<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lang_direction(request):
 """ Sets lang_direction context variable to whether the language is RTL or LTR """

    if lang_direction.rtl_langs is None:
        lang_direction.rtl_langs = getattr(settings, "RTL_LANGUAGES", set())

    return {"lang_direction": "rtl" if request.LANGUAGE_CODE in lang_direction.rtl_langs else "ltr"}