ea0a98 | 2000-07-17 | Andreas Lange | |
|
afcffc | 2000-07-09 | Martin Nilsson | |
#include <module.h>
inherit "module";
constant module_type = MODULE_PARSER;
constant module_name = "Translation module";
constant module_doc = "This module provides an RXML API to the Pike localization system.";
|
ea0a98 | 2000-07-17 | Andreas Lange | | constant thread_safe = 1;
|
9dda09 | 2000-07-21 | Andreas Lange | | constant cvs_version = "$Id: translation_mod.pike,v 1.6 2000/07/21 05:00:11 lange Exp $";
|
ea0a98 | 2000-07-17 | Andreas Lange | |
|
afcffc | 2000-07-09 | Martin Nilsson | |
class TagTranslationRegistration {
inherit RXML.Tag;
constant name = "trans-reg";
|
2de57b | 2000-07-13 | Martin Nilsson | | constant flags = RXML.FLAG_EMPTY_ELEMENT;
|
afcffc | 2000-07-09 | Martin Nilsson | |
|
9dda09 | 2000-07-21 | Andreas Lange | | mapping(string:RXML.Type) req_arg_types =
([ "project" : RXML.t_text(RXML.PEnt) ]);
mapping(string:RXML.Type) opt_arg_types =
([ "path" : RXML.t_text(RXML.PEnt) ]);
|
afcffc | 2000-07-09 | Martin Nilsson | |
class Frame {
inherit RXML.Frame;
array do_return(RequestID id) {
|
b9a702 | 2000-07-15 | Andreas Lange | | if(args->path && args->path!="") {
|
afcffc | 2000-07-09 | Martin Nilsson | | #if constant(Locale.register_project)
|
b9a702 | 2000-07-15 | Andreas Lange | | Locale.register_project(args->project, args->path);
|
afcffc | 2000-07-09 | Martin Nilsson | | #else
|
b9a702 | 2000-07-15 | Andreas Lange | | RoxenLocale.register_project(args->project, args->path);
|
afcffc | 2000-07-09 | Martin Nilsson | | #endif
|
b9a702 | 2000-07-15 | Andreas Lange | | }
|
9dda09 | 2000-07-21 | Andreas Lange | | id->misc->translation_proj = args->project;
|
afcffc | 2000-07-09 | Martin Nilsson | | result = "";
return 0;
}
}
}
class TagTranslate {
inherit RXML.Tag;
constant name = "translate";
|
9dda09 | 2000-07-21 | Andreas Lange | | mapping(string:RXML.Type) opt_arg_types = ([
"id":RXML.t_text(RXML.PEnt),
"project":RXML.t_text(RXML.PEnt),
"variable":RXML.t_text(RXML.PEnt),
"scope":RXML.t_text(RXML.PEnt) ]);
|
afcffc | 2000-07-09 | Martin Nilsson | | class Frame {
inherit RXML.Frame;
|
9dda09 | 2000-07-21 | Andreas Lange | |
array do_return( RequestID id ) {
|
2de57b | 2000-07-13 | Martin Nilsson | | string proj = args->project || id->misc->translation_proj;
|
ea0a98 | 2000-07-17 | Andreas Lange | | #if constant(Locale.translate)
|
b9a702 | 2000-07-15 | Andreas Lange | | string trans = Locale.translate(proj, roxen.locale->get(),
|
9dda09 | 2000-07-21 | Andreas Lange | | (int)args->id || args->id,
|
afcffc | 2000-07-09 | Martin Nilsson | | content);
#else
|
b9a702 | 2000-07-15 | Andreas Lange | | string trans = RoxenLocale.translate(proj, roxen.locale->get(),
|
9dda09 | 2000-07-21 | Andreas Lange | | (int)args->id || args->id,
|
afcffc | 2000-07-09 | Martin Nilsson | | content);
#endif
if(args->variable) {
RXML.user_set_var(args->variable, trans, args->scope);
return 0;
}
result = trans;
return 0;
}
}
}
|