--- loncom/html/adm/help/tex/Developer_Tutorial.tex 2003/08/20 16:17:40 1.1 +++ loncom/html/adm/help/tex/Developer_Tutorial.tex 2003/09/22 19:07:59 1.3 @@ -252,7 +252,7 @@ If Apache is claiming it can't find the something is wrong with your \texttt{loncapa\_apache.conf} file. Please double check the entry to make sure it is in the right place, that it is typed correctly, and that all the lines are present. If it is -still incorrect, please ask for help on the \texttt{lon-capa-dev@mail.msu.edu} +still incorrect, please ask for help on the \texttt{lon-capa-dev@mail.lon-capa.org} list, including a copy of your \texttt{loncapa\_apache.conf} file in the email; either something is wrong that is beyond the scope of this document(other system configuration issues) or you really can't @@ -277,7 +277,7 @@ tail~/var/log/httpd/error\_log Since I can't guess what error you encountered, I'm afraid I can't help you out here. But I do know the code I wrote above worked, so as a last resort try to figure out what is different. If you are absolutely -stumped, please ask for help on the \texttt{lon-capa-dev@mail.msu.edu} +stumped, please ask for help on the \texttt{lon-capa-dev@mail.lon-capa.org} list, including a copy of your \texttt{lontutorial.pm} file in the email; either something is wrong that is beyond the scope of this document (other system configuration issues) or you really can't find @@ -479,8 +479,10 @@ routine takes a \emph{lot} of arguments, takes in a hash reference instead of a traditional list of arguments. For full information about what that function takes, consult the documentation. \texttt{'cols'} will tell the render function what to render in the -navmap; {}``0'' is the standard listing of the resource with a link -to the resource. \texttt{'showParts' => 0} tells the render function +navmap; {}``Apache::lonnavmaps::resource'' is a constant that +indicates the standard listing of the resource with a link +to the resource, which is the first column of the \textbf{NAV} display +you are used to. \texttt{'showParts' => 0} tells the render function not to show individual parts, which will not be useful to us. \texttt{'r' => \$r} passes the Apache response object to the \texttt{render} function, which it uses to provide periodic output to the user by using the @@ -570,7 +572,10 @@ When you hit {}``Increment'', {}``Form s Note this only applies to POST'ed data. If you use GET, the data will appear on the query string. For your code, this will show up in \texttt{\$ENV\{QUERY\_STRING\}}. If you want to invoke LON-CAPA's processing on that string, so you -see the variables in \texttt{\%ENV}, use \texttt{Apache::loncommon::get\_unprocessed\_cgi(\$ENV\{QUERY\_STRING\});}. +see the variables in \texttt{\%ENV}, use +\texttt{Apache::loncommon::get\_unprocessed\_cgi(\$ENV\{QUERY\_STRING\});}. +This is particularly useful for cases where input may be coming in via +either POST or GET. \subsubsection{Adding Checkboxes for Input} @@ -579,7 +584,8 @@ Now we want to add a checkbox column int we have a place to input our selections. In order to do that, we need to provide the rendering code with a subroutine that will take an \texttt{Apache::lonnavmaps::resource} object and return the string -we want to print, including the
'.\&mt('Form submitted').'
'); + +}~else~{ + +~~~~\$r->print(''.\&mt('No form information submitted.').'
'); + +} + +\end{lyxcode} + +Note we do \emph{not} generally want to wrap HTML tags unless we are +absolutely forced to; those are constant across human languages and +would only burder the translators with stuff they should not need to +deal with. + +\item The label of the button we've created: + +\begin{lyxcode} +\$r->print(''); + +\end{lyxcode} + +\end{enumerate} + +Note we only need to wrap things the human user will see; we don't +need to wrap the \texttt{tutorial} parameter to the +\texttt{Apache::lonnet::restore} call, for instance, and in fact wierd +things could happen if we did! Also note that resource names and such +are already as internationalized as they are going to get, so we don't +need to worry about them. + +Since the internationalization system will return the value passed to +\texttt{\&mt} by default if it can't find a translation, it's safe to +internationalize code before translations exist, and in fact it's a +necessary step. + +Also note that punctuation should be wrapped in the \texttt{\&mt} +calls, including things like trailing periods, since not all languages +have the same punctuation standards as English. + +This only covers simple internationalization. This can take you a long +way, but if you encounter a more difficult problem, please send a note +to the \texttt{lon-capa-dev@mail.lon-capa.org} mailing list. + \subsection{Complete Code Listing} For your reference, I include the complete code listing for the tutorial @@ -743,6 +834,8 @@ use~Apache::lonnavmaps; use~Apache::Constants~qw(:common); +use~Apache::lonlocal; + ~ =pod @@ -827,17 +920,17 @@ sub~handler~\{ ~~~~\$r->print('Form~submitted.
'); +~~~~~~~~\$r->print(''~.~\&mt('Form~submitted.')~.'
'); ~~~~\}~else~\{ -~~~~~~~~\$r->print('No~form~information~submitted.
'); +~~~~~~~~\$r->print(''~.~\&mt('No~form~information~submitted.')~.~'
'); ~~~~\} @@ -895,7 +988,9 @@ sub~handler~\{ -~~~~\$r->print(''); +~~~~\$r->print(''); ~~~~\$r->print('