[LON-CAPA-users] language test

Stefan Bisitz st.bisitz at ostfalia.de
Wed Oct 17 11:14:47 EDT 2012


Hi Hon-Kie,

<translated> is used within text fields. LON-CAPA displays corresponding 
to the block with the best fitting language.

&language() is a function to be used in a perl script block to manually 
access the desired language. Please check the official author manual, 
chapter 8.3 "Table: LON-CAPA functions" for the different options.

Keep in mind that there is a hierarchical model in the background to 
decide which language fits best. This includes the server language 
(domain configuration), the LON-CAPA user's language preference and the 
client(!) browser language preference.

Simple example problem:
--------------------------------
<problem>

   <script type="loncapa/perl">
     $bestlanguage = scalar(&languages(['de','en']));
     if ($bestlanguage eq "de") {
         $headline = "Sprache: de";
     } elsif ($bestlanguage eq "en") {
         $headline = "Language: en";
     } else { # default
         $headline = "Language: en (default)";
     }
   </script>

   <startouttext />
     <h1>$headline</h1>
     <p>
     <translated>
         <lang which="de">Deutsch</lang>
         <lang which="en">English</lang>
         <lang which="default">Default</lang>
     </translated>
     </p>
   <endouttext />

</problem>
--------------------------------

Let me know if you need more hints or other examples. I think we should 
extend the help system.

Stefan Bisitz


Am 16.10.2012 17:57 schrieb hkng:
> Hi,
>
> What is the function call (with perl script) to test the language
> setting? Seems like
>
> <translated>
> <lang which="xy">
>
> does not set the perl variable except the default?
>
> Thanks,
> -hk
>
>
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>


More information about the LON-CAPA-users mailing list