Branch: Tag:

2000-11-24

2000-11-24 16:50:38 by Per Hedbor <ph@opera.com>

Locale galore

Rev: server/base_server/basic_defvar.pike:1.22
Rev: server/base_server/config_userdb.pike:1.12
Rev: server/base_server/global_variables.pike:1.51
Rev: server/base_server/module_support.pike:1.83
Rev: server/base_server/roxenlib.pike:1.206
Rev: server/base_server/roxenloader.pike:1.215
Rev: server/base_server/rxml.pike:1.261
Rev: server/config_interface/standard/sites/config_left_item.pike:1.46
Rev: server/etc/include/roxen.h:1.22
Rev: server/etc/modules/Variable.pmod/module.pmod:1.37
Rev: server/modules/compat/compat.pike:1.54
Rev: server/modules/configuration/config_tags.pike:1.127
Rev: server/modules/database/SQLuserdb.pike:1.22
Rev: server/modules/database/sqldb.pike:1.11
Rev: server/modules/database/sqltag.pike:1.66
Rev: server/modules/directories/directories.pike:1.86
Rev: server/modules/directories/indexfiles.pike:1.17
Rev: server/modules/examples/auth.pike:1.3
Rev: server/modules/examples/common_api.pike:1.4
Rev: server/modules/examples/fnord.pike:1.12
Rev: server/modules/examples/newstyle_fnord.pike:1.9
Rev: server/modules/filesystems/filesystem.pike:1.90
Rev: server/modules/tags/obox.pike:1.32

1:   inherit "module";   // All roxen modules must inherit module.pike + #include <roxen.h> + // include roxen.h for locale specific stuff    - constant cvs_version = "$Id: common_api.pike,v 1.3 2000/08/25 17:44:18 jhs Exp $"; + // Some defines for the translation system + // + //<locale-token project="mod_common_api">LOCALE</locale-token> + #define LOCALE(X,Y) _DEF_LOCALE("mod_common_api",X,Y) + // end of the locale related stuff +  + constant cvs_version="$Id: common_api.pike,v 1.4 2000/11/24 16:50:37 per Exp $";   //! This string (filtered to remove some ugly cvs id markup) shows up in   //! the roxen administration interface when handling module parameters in   //! developer mode (configured under "User Settings" below the Admin tab).
9:   //! the file in the inherit tree. Optional, but convenient, especially if   //! you use cvs for version control of your code.    - constant module_name = "Tamaroxchi"; + LocaleString module_name_locale = LOCALE(0,"Tamaroxchi");   //! The name that will show up in the module listings when adding modules   //! or viewing the modules of a virtual server. Keep it fairly informative   //! and unique, since this is the only means for identification of your
20:   //! (|) for hybrid modules. Hybrid modules must implement the required   //! API functions for all of the module types they are hybrids of.    - constant module_doc = "This module does nothing, but its inlined " -  "documentation gets imported into the roxen " -  "programmer manual. You really don't want to " -  "add this module to your virtual server, promise!"; + LocaleString module_doc_locale = LOCALE(0,"This module does nothing, but its " +  "inlined documentation gets imported " +  "into the roxen programmer manual. " +  "You really don't want to add this " +  "module to your virtual server, promise!");   //! The documentation string that will end up in the administration   //! interface view of the module just below the module name. Also shows   //! up in the more verbose add module views.
74:   //! object in the admin interface sent with the request used to invoke the   //! action by the administrator.   { -  return ([ "Scratch me!" : scratch_me ]); +  return ([ LOCALE(0,"Scratch me!") : scratch_me ]);   }      void scratch_me()
83:    if(itching)    {    itching = 0; -  report_notice("Aah, that's good.\n"); +  report_notice(LOCALE(0,"Aah, that's good.\n"));    } else -  report_warning("Ouch!\n"); +  report_warning(LOCALE(0,"Ouch!\n"));   }    - string info( Configuration|void conf ) + LocaleString info( Configuration conf )   //! Implementing this function in your module is optional.   //!   //! When present, it returns a string that describes the module. - //! When absent, Roxen will use element <ref>module_doc</ref>. Unlike - //! module_doc, though, this information is only shown when the module + //! When absent, Roxen will use element <ref>module_doc_locale</ref>. Unlike + //! module_doc_locale, though, this information is only shown when the module   //! is present in a virtual server, so it won't show up when adding   //! modules to a server.   {    string mp = query_internal_location(); -  return "This string overrides the documentation string given in " -  "module_doc, but only once the module is added to a server. " -  "The module's internal mountpoint is found at <tt>" + -  mp + "</tt>."; +  +  return sprintf(LOCALE(0,"This string overrides the documentation string " +  "given in module_doc[_locale], but only once the " +  "module is added to a server. The module's internal " +  "mountpoint is found at <tt>%s</tt>"), mp );   }    - string|void check_variable(string variable, mixed set_to) + LocaleString check_variable(string variable, mixed set_to)   //! Custom checks of configuration variable validities. (optional)   //!   //! Check admin interface variables for sanity.
120:    {    // find out if it's a value we'll accept... if so, then just return.    if(set_to=="whatevervalueweaccept") -  return; +  return 0;    else // if it's not, return an error message. -  return "Sorry, we don't accept that value...\n"; +  return LOCALE(0,"Sorry, we don't accept that value.")+"\n";    }   }   
141:   //! also happens just before calling <ref>stop()</ref> upon reloading   //! the module.   { -  report_notice("Wow, I feel good!\n"); +  report_notice(LOCALE(0,"Wow, I feel good!")+"\n");   }      void stop()
151:   //! when the administrator drops the module, reloads the module or   //! when the server is being shut down.   { -  report_notice("'Guess that's what I get for all this itching. *sigh*\n"); +  report_notice(LOCALE(0,"Guess that's what I get for all this itching. *sigh*")+"\n");   }      string status()
167:       switch(itching)    { -  case 0: return "Feelin' fine."; -  case 1: how_much = "a bit."; break; -  case 2: how_much = "noticeably."; break; -  case 3: how_much = "quite a bit."; break; -  case 4: how_much = "really much."; break; -  case 5: how_much = "a lot."; break; -  case 6: how_much = "unbearably!"; break; -  default: how_much = "more than any sane person could stand!"; +  case 0: return LOCALE(0,"Feelin' fine."); +  case 1: how_much = LOCALE(0,"a bit"); break; +  case 2: how_much = LOCALE(0,"noticeably"); break; +  case 3: how_much = LOCALE(0,"quite a bit"); break; +  case 4: how_much = LOCALE(0,"really much"); break; +  case 5: how_much = LOCALE(0,"a lot"); break; +  case 6: how_much = LOCALE(0,"unbearably"); break; +  default: how_much = LOCALE(0,"more than any sane person could stand");    } -  return sprintf("I'm itching %s Please scratch me!", how_much); +  return sprintf(LOCALE(0,"I'm itching %s. Please scratch me!"), how_much);   }    - mapping|int|Stdio.File|void find_internal(string file, RequestID id) + mapping|int|Stdio.File find_internal(string file, RequestID id)   //! Internal magic location. May return a result mapping,   //! -1 for a directory indicator, an open file descriptor   //! or 0, signifying file not found / request not handled.