Locale Display Example

This AllegroServe example demonstrates how one can use locales to affect a server page's display. Since the locale environment is determined by the binding of excl:*locale*, it is easy and natural to have a single Lisp server process operating in several different locales simultaneously.

If this example is loaded into an AllegroServe WWW server, then you can click here for a live demo of the example.

Notes about this example:

The source file can be used for three different purposes:

  1. Lisp session direct calls.
  2. One can load locex.cl into a Lisp session and call the core function, html-locale-display. This function's purpose is to illustrate how one can simply change the locale, by binding *locale*, to affect the locale specific functions and format directives.

    Example:

    (with-open-file (s "output.html" :direction :output)
      (locex:html-locale-display s "en_US"))
    
    creates a file named output.html using the en_US locale.

    Alternatively, you can just do the following to see the html output directly:

    (locex:html-locale-display *standard-output* "en_US")
    
  3. Single-use application.
  4. One can load locex.cl into a Lisp session and then call generate-single-use-application to generate a single-use application in the newly created directory, locex-su/. After being created, the application can be called from the OS shell.

    Example:
    % locex-su/locex-su -o output.html -l en_US [For Unix]
    > locex-su\locex-su -o output.html -l en_US [For Windows]
    creates the file output.html (in UTF-8) using the en_US locale.

  5. Standalone server application.
  6. One can load locex.cl into a Lisp session and then call generate-server-application to generate a standalone server application in the new directory locex-server/. After being created, the application can be called from the OS shell.

    Example:
    % locex-server/locex-server -p 8010 [For Unix]
    > locex-server\locex-server -p 8010 [For Windows]
    starts an http server on port 8010 of the current host. Use a browser to visit the server on the specified port. For example, if the host running the server is foo.franz.com, then you can use a browser to visit http://foo.franz.com:8010.

    Note: There is no prescribed way to exit from locex-server. Adding such a way is an exercise left to the reader. In the meantime, to stop the locex-server, simply terminate OS process.

Original code author: Charles A. Cox, Franz Inc.