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

1.1       bisitz      1: \label{Authoring_Multilingual}
                      2: \textbf{How to write problems in different languages?}
                      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: 
                     10: \textbf{Problem Template}
                     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: 
                     19: \textbf{Different languages in a text block}
                     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.2     ! bisitz     61: \textbf{Different languages in options, variables, etc.}
        !            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.1       bisitz     87: \textbf{Interface language vs. problem language}
                     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: 
                     97: \textbf{Language Codes}
                     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: 
                    121: \textbf{Consistent language with <translated> and \&languages()}
                    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: 
                    128: \textbf{Testing multilingual problems}
                    129: 
                    130: You can temporarily change the language for a problem in the \emph{Problem
                    131: Testing} screen. Use the ``Language'' dropdown list to choose the language
                    132: to be used for testing and click \fbox{Change View}.
                    133: 
                    134: Note: Your own personal settings apply, including your browser settings (see
                    135: below).
                    136: 
                    137: 
                    138: \textbf{Language hierarchy model in LON-CAPA}
                    139: 
                    140: LON-CAPA uses the best fitting language by considering the following settings
                    141: (if available), in the order as follows:
                    142: \begin{enumerate}
                    143: \item Overall default: English
                    144: \item Server setting (see Domain Configuration \ref{Domain_Configuration_LangTZAuth})
                    145: \item User's language preference(s) in the web browser (client side)
                    146: \item User preference: Language \ref{Prefs_Language}
                    147: \item Course setting (see Course Configuration \ref{Course_Prefs_Language})
                    148: \item Individual problem content (e.g. hard coded language)
                    149: \end{enumerate}
                    150: 
                    151: Example 1:
                    152: 
                    153: The server is set to French, the user's preference in LON-CAPA is set to
1.2     ! bisitz    154: prefer Spanish, the problem is programmed to offer Portuguese and Spanish,
1.1       bisitz    155: and the problem default language is German.
                    156: LON-CAPA shows this problem in Spanish to the student.
                    157: 
                    158: Example 2:
                    159: 
                    160: The server is set to French, the user's preference in LON-CAPA is set to
                    161: prefer Spanish, the problem is programmed to offer Turkish and Portuguese,
                    162: and the problem default language is German.
                    163: LON-CAPA shows this problem in French to the student.
                    164: 
                    165: Example 3:
                    166: 
                    167: The user's preference in LON-CAPA is set to prefer Spanish, the problem
                    168: is programmed to offer French and Portuguese, and the problem default language
                    169: is German.
                    170: LON-CAPA shows this problem in German to the student.
                    171: 
                    172: 
                    173: \textbf{Legacy code with <languageblock>}
                    174: 
                    175: Some old problems might contain the \textbf{<languageblock>} tag. This tag is
                    176: deprecated and it is discouraged to use it. The functionality is different to
                    177: <translated>. It does not fully support the practical needs for offering
                    178: multilingual problems. If you adapt such a problem for your own purposes, it
                    179: is recommended to replace <languageblock> by <translated> as described above.
                    180: 

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