Annotation of loncom/html/adm/help/tex/Authoring_Multilingual_Problems.tex, revision 1.4

1.3       bisitz      1: \label{Authoring_Multilingual_Problems}
1.4     ! bisitz      2: \section*{How to write problems in different languages?}
1.1       bisitz      3: 
                      4: LON-CAPA offers the optional possibility to create multilingual problems.
                      5: You can use different languages for the task text and also for the options and
                      6: all other texts shown to the student. LON-CAPA automatically finds the best
                      7: fitting language for the texts to show to your students.
                      8: 
                      9: 
1.4     ! bisitz     10: \subsection*{Problem Template}
1.1       bisitz     11: 
                     12: A good point to start is to select the template \textbf{Option Response -
                     13: Matching (multilingual)} when creating a new problem. You can see there how
                     14: to show texts and options in an optionresponse problem
                     15: \ref{Authoring_OptionResponse} in different languages. More details how to
                     16: write such problems as follows.
                     17: 
                     18: 
1.4     ! bisitz     19: \subsection*{Different languages in a text block}
1.1       bisitz     20: 
                     21: Text to show to students is surrounded by <startouttext /> and <endouttext>.
                     22: If you use only one language, just type your text within these tags:
                     23: 
                     24: \begin{verbatim}
                     25: <startouttext />
                     26: English question
                     27: <endouttext />
                     28: \end{verbatim}
                     29: 
                     30: If you want to offer your text with more than one language, use the
                     31: \textbf{<translated>} tag within the <startouttext> / <endouttext> tag. Type
                     32: your text for each language in a \textbf{<lang>} tag. Specify the language code
                     33: in the attribute ``which'', e.g. ``en'' for English or ``de'' for German.
                     34: When the problem is presented to your students, LON-CAPA will automatically
                     35: choose the best language fitting to the user's environment taking care of
                     36: personal preferences. Details see below.
                     37: 
                     38: Don't forget to always have a \textbf{default language} present. If the default
                     39: was missing and LON-CAPA didn't find any fitting language, no text at all would
                     40: be shown to the student. It is recommended to use English as default or -
                     41: depending on the field of application - the language which fits best in the
                     42: context where the problem will be likely used.
                     43: 
                     44: Example (three different languages and default):
                     45: \begin{verbatim}
                     46: <startouttext />
                     47:    <translated>
                     48:        <lang which="en">English question</lang>
                     49:        <lang which="de">Deutscher Aufgabentext</lang>
                     50:        <lang which="fr">Texte de la question en français</lang>
                     51:        <lang which="default">English question</lang>
                     52:    </translated>
                     53: <endouttext />
                     54: \end{verbatim}
                     55: 
                     56: Add a <lang> tag and the corresponding text for each additional language. Watch
                     57: out to extend all <translated> tags within this problem in this way to have a
                     58: consistent language for all texts in the problem.
                     59: 
                     60: 
1.4     ! bisitz     61: \subsection*{Different languages in options, variables, etc.}
1.2       bisitz     62: 
                     63: If you use a script block to create dynamic content and it contains text, the
                     64: \textbf{\&languages()} function is used to offer these texts in different
                     65: languages. This function can be called in different ways, see Script Functions
                     66: \ref{Problem_LON-CAPA_Functions}.
                     67: One way is to provide the language codes for the languages you like to support
                     68: in an anonymous array to the function and get back the best fitting language of
                     69: those. Use the returned language code to decide which text in which language
                     70: should be used. 
                     71: 
                     72: Example:
                     73: \begin{verbatim}
                     74: <script type="loncapa/perl">
                     75: &bestlanguage = &languages(['en','de','fr']);
                     76: if ($bestlanguage eq 'de') {
                     77:    $optiontext = 'rot';
                     78: } elsif ($bestlanguage eq 'fr') {
                     79:    $optiontext = 'rouge';
                     80: } else { # 'en' and default
                     81:    $optiontext = 'red';
                     82: }
                     83: </script>
                     84: \end{verbatim}
                     85: 
                     86: 
1.4     ! bisitz     87: \subsection*{Interface language vs. problem language}
1.1       bisitz     88: 
                     89: LON-CAPA supports various languages for the web interface, e.g. for menu items
                     90: and help files. These languages are not necessarily dependent on the languages
                     91: offered within problems. I.e. it is possible to have the web interface shown
                     92: in Chinese and a problem is shown in Turkish. However, the user's language
                     93: preference is considered when the interface is rendered and also when the best
                     94: fitting language for texts in a problem is chosen. Details see below.
                     95: 
                     96: 
1.4     ! bisitz     97: \subsection*{Language Codes}
1.1       bisitz     98: 
                     99: Some language codes which can be used in the <lang> tag within the <translated>
                    100: tag:
                    101: \begin{itemize}
                    102: \item ar - Arabic
                    103: \item de - German
                    104: \item en - English
                    105: \item es - Spanish
                    106: \item fa - Persian
                    107: \item fr - French
                    108: \item he - Hebrew
                    109: \item ja - Japanese
                    110: \item pt - Portuguese
                    111: \item ru - Russian
                    112: \item tr - Turkish
                    113: \item zh - Chinese (Simplified)
                    114: \end{itemize}
                    115: 
                    116: These languages are currently also available as interface language, see
                    117: Language \ref{Prefs_Language} in the User Preferences section.
                    118: You can use other languages in your problems.
                    119: 
                    120: 
1.4     ! bisitz    121: \subsection*{Consistent language with <translated> and \&languages()}
1.1       bisitz    122: 
                    123: If you use both, <translated> and \&languages(), in your problem, always make
                    124: sure to keep the languages synchronized. Use exactly the same language codes
                    125: for the \&languages() call like those used in the <lang> tags within
                    126: <translated>.
                    127: 
1.4     ! bisitz    128: 
        !           129: \subsection*{Testing multilingual problems}
1.1       bisitz    130: 
                    131: You can temporarily change the language for a problem in the \emph{Problem
                    132: Testing} screen. Use the ``Language'' dropdown list to choose the language
                    133: to be used for testing and click \fbox{Change View}.
                    134: 
                    135: Note: Your own personal settings apply, including your browser settings (see
                    136: below).
                    137: 
                    138: 
1.4     ! bisitz    139: \subsection*{Language hierarchy model in LON-CAPA}
1.1       bisitz    140: 
                    141: LON-CAPA uses the best fitting language by considering the following settings
                    142: (if available), in the order as follows:
                    143: \begin{enumerate}
                    144: \item Overall default: English
                    145: \item Server setting (see Domain Configuration \ref{Domain_Configuration_LangTZAuth})
                    146: \item User's language preference(s) in the web browser (client side)
                    147: \item User preference: Language \ref{Prefs_Language}
                    148: \item Course setting (see Course Configuration \ref{Course_Prefs_Language})
                    149: \item Individual problem content (e.g. hard coded language)
                    150: \end{enumerate}
                    151: 
                    152: Example 1:
                    153: 
                    154: The server is set to French, the user's preference in LON-CAPA is set to
1.2       bisitz    155: prefer Spanish, the problem is programmed to offer Portuguese and Spanish,
1.1       bisitz    156: and the problem default language is German.
                    157: LON-CAPA shows this problem in Spanish to the student.
                    158: 
                    159: Example 2:
                    160: 
                    161: The server is set to French, the user's preference in LON-CAPA is set to
                    162: prefer Spanish, the problem is programmed to offer Turkish and Portuguese,
                    163: and the problem default language is German.
                    164: LON-CAPA shows this problem in French to the student.
                    165: 
                    166: Example 3:
                    167: 
                    168: The user's preference in LON-CAPA is set to prefer Spanish, the problem
                    169: is programmed to offer French and Portuguese, and the problem default language
                    170: is German.
                    171: LON-CAPA shows this problem in German to the student.
                    172: 
                    173: 
1.4     ! bisitz    174: \subsection*{Legacy code with <languageblock>}
1.1       bisitz    175: 
                    176: Some old problems might contain the \textbf{<languageblock>} tag. This tag is
                    177: deprecated and it is discouraged to use it. The functionality is different to
                    178: <translated>. It does not fully support the practical needs for offering
                    179: multilingual problems. If you adapt such a problem for your own purposes, it
                    180: is recommended to replace <languageblock> by <translated> as described above.
                    181: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>