NAME

WeBWorK::Utils::LanguageAndDirection - utilities to determine the language and text direction for a page based on language, or for a problem based on settings from the PG flags, the course configuration variable $perProblemLangAndDirSettingMode, and the course language.

SYNOPSIS

use WeBWorK::Utils::LanguageAndDirection;

DESCRIPTION

This module provides functions to determine the language and text direction for a page based on language, or for a problem based on settings from the PG flags, the course configuration variable $perProblemLangAndDirSettingMode, and the course language.

FUNCTIONS

get_lang_and_dir()

Returns the LANG attribute and when needed the DIR attribute based on the language.

It selects the language based on the given language code and otherwise defaults to lang="en-US".

When the language chosen is a known right to left language, it will also set the DIR attribute to "rtl". Currently, only Hebrew ("heb" or "he") and Arabic ("ar") trigger the RTL direction setting.

get_problem_lang_and_dir subroutine
@output = get_problem_lang_and_dir($pg_flags, $requested_mode, $lang);
or
$output = get_problem_lang_and_dir($pg_flags, $requested_mode, $lang);

Used to determine the language and maybe also the dir setting for the DIV tag attributes, if needed by the PROBLEM language.

$pg_flags is a reference to the "flags" hash of a pg problem.

$requested_mode is optional, and if provided should be a string containing the mode (one of "force", "auto", or ""), language code, and direction separated by colons. Alternately $requested_mode may be "none". If it is "none" or undefined the return result is empty.

$lang is also optional, and should the language code if provided.

Return a hash of key-value pairs (eg. lang => "eng", dir => "ltr") in list context, and a string (eg. ' lang="eng" dir="ltr"') in scalar context. In some cases, the return result is empty.

AUTHOR

Written by Nathan Wallach, tani (at) mathnet.technion.ac.il