afcffc2000-07-09Martin Nilsson // This is a roxen module. Copyright © 2000, Roxen IS. // #include <module.h> inherit "module"; // ---------------- Module registration stuff ---------------- constant module_type = MODULE_PARSER; constant module_name = "Translation module"; constant module_doc = "This module provides an RXML API to the Pike localization system."; // ------------------------ The tags ------------------------- class TagTranslationRegistration { inherit RXML.Tag; constant name = "trans-reg";
2de57b2000-07-13Martin Nilsson  constant flags = RXML.FLAG_EMPTY_ELEMENT;
afcffc2000-07-09Martin Nilsson  mapping(string:RXML.Type) req_arg_types = ([ "project":RXML.t_text, "path":RXML.t_text ]); class Frame { inherit RXML.Frame; array do_return(RequestID id) {
b9a7022000-07-15Andreas Lange  if(args->path && args->path!="") {
afcffc2000-07-09Martin Nilsson #if constant(Locale.register_project)
b9a7022000-07-15Andreas Lange  Locale.register_project(args->project, args->path);
afcffc2000-07-09Martin Nilsson #else
b9a7022000-07-15Andreas Lange  RoxenLocale.register_project(args->project, args->path);
afcffc2000-07-09Martin Nilsson #endif
b9a7022000-07-15Andreas Lange  }
2de57b2000-07-13Martin Nilsson  id->misc->translation_proj=args->project;
afcffc2000-07-09Martin Nilsson  result = ""; return 0; } } } class TagTranslate { inherit RXML.Tag; constant name = "translate";
2de57b2000-07-13Martin Nilsson  mapping(string:RXML.Type) req_arg_types = ([ "id":RXML.t_text ]); mapping(string:RXML.Type) opt_arg_types = ([ "project":RXML.t_text, "variable":RXML.t_text,
afcffc2000-07-09Martin Nilsson  "scope":RXML.t_text ]); class Frame { inherit RXML.Frame; array do_return(RequestID id) {
2de57b2000-07-13Martin Nilsson  string proj = args->project || id->misc->translation_proj;
afcffc2000-07-09Martin Nilsson #if constant(Locale.transtale)
b9a7022000-07-15Andreas Lange  string trans = Locale.translate(proj, roxen.locale->get(),
afcffc2000-07-09Martin Nilsson  args->id, content); #else
b9a7022000-07-15Andreas Lange  string trans = RoxenLocale.translate(proj, roxen.locale->get(),
afcffc2000-07-09Martin Nilsson  args->id, content); #endif if(args->variable) { RXML.user_set_var(args->variable, trans, args->scope); return 0; } result = trans; return 0; } } }