Commit 0ae0b51a authored by claes's avatar claes

Support for language specific doc files for classes added

parent 622fc219
......@@ -10,6 +10,7 @@ extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
}
#include "co_lng.h"
#include "cnv_ctx.h"
#include "cnv_readwbl.h"
#include "cnv_wblto.h"
......@@ -969,6 +970,12 @@ void CnvReadWbl::doc_init()
doc_group_cnt = 0;
}
void CnvReadWbl::doc_init_keep()
{
doc_cnt = 0;
strcpy( doc_summary, "");
}
int CnvReadWbl::doc_add( char *line)
{
char line_part[4][80];
......@@ -1244,3 +1251,105 @@ char *CnvReadWbl::flags_to_string( int value)
}
return str;
}
int CnvReadWbl::read_lng( char *cname, char *aname)
{
char line[400];
char str[400];
char key[80];
char found_key[80];
int in_class;
int in_doc;
int sts;
int len;
FILE *fp;
pwr_tFileName filename = "pwrb_sv_se.txt";
sprintf( filename, "%s/%s_%s.txt", source_dir, CnvCtx::low(volume_name),
Lng::get_language_str());
strcpy( key, cname);
if ( aname && strcmp(aname, "") != 0) {
strcat( key, "-");
strcat( key, aname);
}
dcli_translate_filename( filename, filename);
fp = fopen( filename, "r");
if ( !fp) return 0;
in_class = 0;
in_doc = 0;
while( 1) {
sts = CnvCtx::read_line( line, sizeof(line), fp);
if ( !sts) break;
CnvCtx::remove_spaces( line, str);
if ( cdh_NoCaseStrncmp( str, "<class>", 7) == 0)
len = 7;
else if ( cdh_NoCaseStrncmp( str, "<type>", 6) == 0)
len = 6;
else if ( cdh_NoCaseStrncmp( str, "<typedef>", 9) == 0)
len = 9;
else
len = 0;
if ( len) {
CnvCtx::remove_spaces( &str[len], found_key);
if ( cdh_NoCaseStrcmp( cname, found_key) == 0) {
if ( aname && strcmp(aname, "") != 0) {
in_class = 1;
}
else {
in_doc = 1;
in_class = 1;
doc_init_keep();
}
}
continue;
}
else if ( in_class &&
(cdh_NoCaseStrncmp( str, "</class>", 8) == 0 ||
cdh_NoCaseStrncmp( str, "</type>", 7) == 0 ||
cdh_NoCaseStrncmp( str, "</typedef>", 10) == 0))
break;
else if ( in_class &&
(cdh_NoCaseStrncmp( str, "<attr>", 6) == 0 ||
cdh_NoCaseStrncmp( str, "<value>", 7) == 0)) {
if ( cdh_NoCaseStrncmp( str, "<attr>", 6) == 0)
len = 6;
else
len = 7;
if ( !in_class)
continue;
if ( in_doc)
break;
CnvCtx::remove_spaces( &str[len], found_key);
if ( cdh_NoCaseStrcmp( aname, found_key) == 0) {
in_doc = 1;
doc_init_keep();
}
}
else if ( in_doc &&
(cdh_NoCaseStrncmp( str, "</attr>", 8) == 0 ||
cdh_NoCaseStrncmp( str, "</value>", 9) == 0)) {
if ( !in_class)
continue;
break;
}
else if ( in_doc) {
strcpy( str, "! ");
strcat( str, line);
doc_add( str);
}
}
fclose( fp);
if ( in_doc) {
doc_close();
return 1;
}
return 0;
}
......@@ -202,6 +202,7 @@ class CnvReadWbl {
int template_attr( char *name, char *value);
int template_close();
void doc_init();
void doc_init_keep();
int doc_add( char *line);
int doc_close();
void volume_init();
......@@ -209,6 +210,7 @@ class CnvReadWbl {
char *low( char *in);
int copy_tmp_file( char *tmpfilename, ofstream& fp_to);
char *flags_to_string( int value);
int read_lng( char *cname, char *aname);
};
#if defined __cplusplus
......
......@@ -14,7 +14,7 @@ extern "C" {
#include "co_cdh.h"
#include "co_time.h"
}
#include "co_lng.h"
int CnvWblToHtml::init( char *first)
{
......@@ -378,7 +378,7 @@ int CnvWblToHtml::close()
#endif
char cmd[200];
sprintf( cmd, "cat %s/*.jsf %s/../orm_menu.js > %s/menu.js", ctx->dir,
sprintf( cmd, "cat %s/*.jsf %s/../../orm_menu.js > %s/menu.js", ctx->dir,
ctx->dir, ctx->dir);
system( cmd);
......@@ -398,6 +398,10 @@ int CnvWblToHtml::class_exec()
char low_class_name[80];
char txt[200];
char timestr[80];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->class_name, 0);
time_AtoAscii( 0, time_eFormat_DateAndTime, timestr, sizeof(timestr));
......@@ -525,22 +529,22 @@ endl <<
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0)
{
html_clf->f <<
"<DT><B>Author</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_author << "<DT>" << endl;
"<DT><B>" << Lng::translate("Author") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_author << "<DT>" << endl;
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0)
{
html_clf->f <<
"<DT><B>Version</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_version << "<DT>" << endl;
"<DT><B>" << Lng::translate("Version") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->doc_version << "<DT>" << endl;
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0)
{
html_clf->f <<
"<DT><B>Code</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << ref_name << "#" << low_class_name << "\"><FONT size=\"-1\">" << ctx->rw->doc_code << "</FONT></A><DT>" << endl;
"<DT><B>" << Lng::translate("Code") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF=\"" << ref_name << "#" << low_class_name << "\"><FONT size=\"-1\">" << ctx->rw->doc_code << "</FONT></A><DT>" << endl;
}
html_clf->f <<
"<BR><DT><B>Description</B><DT><BR>" << endl <<
"<BR><DT><B>" << Lng::translate("Description") << "</B><DT><BR>" << endl <<
"</DL><DIV ID=\"description\"><XMP>" << endl;
if ( ctx->rw->doc_fresh) {
......@@ -733,6 +737,10 @@ int CnvWblToHtml::attribute_exec()
char txt[200];
char typeref_href[80];
char attrtype_href[80];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->class_name, ctx->rw->attr_name);
if ( strncmp( ctx->rw->attr_typeref, "pwr_eClass_", 11) == 0) {
strcpy( typeref_href, &ctx->rw->attr_typeref[11]);
......@@ -825,16 +833,16 @@ int CnvWblToHtml::attribute_exec()
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of pointers to <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
"<CODE><B>" << Lng::translate("Type") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of pointers to <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
else if ( ctx->rw->attr_array)
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
"<CODE><B>" << Lng::translate("Type") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
else if ( ctx->rw->attr_pointer)
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pointer to <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
"<CODE><B>" << Lng::translate("Type") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pointer to <A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
else
fp_tmp <<
"<CODE><B>Type</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
"<CODE><B>" << Lng::translate("Type") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << typeref_href << "\">" << ctx->rw->attr_typeref << "</A></CODE><DT>" << endl;
fp_tmp <<
"<DT><CODE><B><A HREF=\"" << attrtype_href << "#Flags\">Flags</A></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->attr_flags << "</CODE><DT>" << endl;
......@@ -844,12 +852,13 @@ int CnvWblToHtml::attribute_exec()
"<DT><CODE><B>Elements</B>&nbsp;&nbsp;" << ctx->rw->attr_elements << "</CODE><DT>" << endl;
fp_tmp <<
"<DT><CODE><B>Body</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->body_name << "</CODE><DT>" << endl <<
"<DT><CODE><B>Class</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << attrtype_href << "\">$" << ctx->rw->attr_type << "</A></CODE><DT>" << endl;
"<DT><CODE><B>" << Lng::translate("Body") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" << ctx->rw->body_name << "</CODE><DT>" << endl;
fp_tmp <<
"<DT><CODE><B>" << Lng::translate("Class") << "</B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"" << attrtype_href << "\">$" << ctx->rw->attr_type << "</A></CODE><DT>" << endl;
fp_tmp <<
"<BR>" << endl <<
"<CODE><B>Description</B></CODE><DT></DL>" << endl <<
"<CODE><B>" << Lng::translate("Description") << "</B></CODE><DT></DL>" << endl <<
"<DIV ID=\"description\"><XMP>" << endl;
if ( ctx->rw->doc_fresh) {
......@@ -885,6 +894,10 @@ int CnvWblToHtml::bit_exec()
{
int i;
char txt[200];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->typedef_name, ctx->rw->bit_name);
// Summary
char bitchar = _tolower(ctx->rw->typedef_typeref[0]);
......@@ -985,6 +998,10 @@ int CnvWblToHtml::typedef_exec()
char low_class_name[80];
char txt[200];
char code_aref[200];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->typedef_name, 0);
strcpy( ctx->rw->class_name, ctx->rw->typedef_name);
......
......@@ -57,6 +57,7 @@ class CnvWblToHtml : public CnvWblTo {
int bit_exec();
Cnv_eWblToType type() { return Cnv_eWblToType_Html;}
int class_open() { return html_class_open;}
int index_open() { return html_index_open;}
};
......
......@@ -26,6 +26,8 @@ int CnvWblToPs::init( char *first)
strcpy( fname, ctx->dir);
strcat( fname, ctx->rw->volume_name);
strcat( fname, "_");
strcat( fname, Lng::get_language_str());
strcat( fname, ".ps");
cdh_ToLower( fname, fname);
......@@ -39,8 +41,8 @@ int CnvWblToPs::init( char *first)
tops.y -= 100;
tops.print_image("pwr_logga.gif");
tops.y -= 100;
tops.print_h2( "Object Reference Manual");
tops.print_h3( "Volume");
tops.print_h2( Lng::translate("Object Reference Manual"));
tops.print_h3( Lng::translate("Volume"));
tops.print_h2( ctx->rw->volume_name);
tops.y -= 150;
tops.print_horizontal_line();
......@@ -74,6 +76,10 @@ int CnvWblToPs::class_exec()
char link_ref[80];
char *s;
char txt[256];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->class_name, 0);
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
......@@ -81,25 +87,30 @@ int CnvWblToPs::class_exec()
tops.set_pageheader( full_class_name);
sprintf( txt, "Class %s", ctx->rw->class_name);
sprintf( txt, "%s %s", Lng::translate("Class"), ctx->rw->class_name);
tops.print_h1( txt, 0, CnvCtx::low( ctx->rw->class_name));
if ( !lng_sts) {
sprintf( txt, "(%s)", Lng::translate( "English text not available"));
tops.print_text( txt, tops.style[tops.ci].link);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0) {
sprintf( txt, "Author %s", ctx->rw->doc_author);
sprintf( txt, "%s %s", Lng::translate("Author"), ctx->rw->doc_author);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0) {
sprintf( txt, "Version %s", ctx->rw->doc_version);
sprintf( txt, "%s %s", Lng::translate("Version"), ctx->rw->doc_version);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0) {
sprintf( txt, "Code %s", ctx->rw->doc_code);
sprintf( txt, "%s %s", Lng::translate("Code"), ctx->rw->doc_code);
tops.print_text( txt, tops.style[tops.ci].text);
}
tops.print_h2( "Description");
tops.print_h2( Lng::translate("Description"));
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
CnvCtx::remove_spaces( ctx->rw->doc_text[i], txt);
......@@ -169,9 +180,9 @@ int CnvWblToPs::body_exec()
tops.y -= 10;
tops.print_horizontal_line();
sprintf( text, "Body %s", ctx->rw->body_name);
sprintf( text, "%s %s", Lng::translate("Body"), ctx->rw->body_name);
tops.print_h2( text);
sprintf( text, "Struct %s", ctx->rw->body_structname);
sprintf( text, "Struct pwr_sClass_%s", ctx->rw->body_structname);
tops.print_text( text, tops.style[tops.ci].boldtext);
if ( strcmp( ctx->rw->body_flags, "") != 0) {
sprintf( text, "Flags %s", ctx->rw->body_flags);
......@@ -193,18 +204,23 @@ int CnvWblToPs::attribute_exec()
char txt[200];
char text[200];
int page;
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->class_name, ctx->rw->attr_name);
tops.print_h3( ctx->rw->attr_name);
if ( ctx->rw->attr_array && ctx->rw->attr_pointer)
sprintf( txt, "Type Array[%s] of pointers to %s", ctx->rw->attr_elements,
ctx->rw->attr_typeref);
sprintf( txt, "%s Array[%s] of pointers to %s", Lng::translate("Type"),
ctx->rw->attr_elements, ctx->rw->attr_typeref);
else if ( ctx->rw->attr_array)
sprintf( txt, "Type Array[%s] of %s", ctx->rw->attr_elements,
ctx->rw->attr_typeref);
sprintf( txt, "%s Array[%s] of %s", Lng::translate("Type"),
ctx->rw->attr_elements, ctx->rw->attr_typeref);
else if ( ctx->rw->attr_pointer)
sprintf( txt, "Type Pointer to %s", ctx->rw->attr_typeref);
sprintf( txt, "%s Pointer to %s", Lng::translate("Type"),
ctx->rw->attr_typeref);
else
sprintf( txt, "Type %s", ctx->rw->attr_typeref);
sprintf( txt, "%s %s", Lng::translate("Type"), ctx->rw->attr_typeref);
int sts = tops.content.find_link( CnvCtx::low(ctx->rw->attr_typeref), text, &page);
if ( ODD(sts)) {
......@@ -216,7 +232,7 @@ int CnvWblToPs::attribute_exec()
else
tops.print_text( txt, tops.style[tops.ci].boldtext);
sprintf( txt, "Class %s", ctx->rw->attr_type);
sprintf( txt, "%s %s", Lng::translate("Class"), ctx->rw->attr_type);
tops.print_text( txt, tops.style[tops.ci].boldtext);
if ( strcmp( ctx->rw->attr_flags, "") != 0) {
......@@ -252,6 +268,10 @@ int CnvWblToPs::typedef_exec()
char link_ref[80];
char *s;
char txt[256];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->typedef_name, 0);
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
......@@ -259,9 +279,14 @@ int CnvWblToPs::typedef_exec()
tops.set_pageheader( full_class_name);
sprintf( txt, "Type %s", ctx->rw->typedef_name);
sprintf( txt, "%s %s", Lng::translate("Type"), ctx->rw->typedef_name);
tops.print_h1( txt, 0, CnvCtx::low( ctx->rw->typedef_name));
if ( !lng_sts) {
sprintf( txt, "(%s)", Lng::translate( "English text not available"));
tops.print_text( txt, tops.style[tops.ci].link);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->typedef_typeref, "") != 0) {
sprintf( txt, "TypeRef %s", ctx->rw->typedef_typeref);
tops.print_text( txt, tops.style[tops.ci].boldtext);
......@@ -278,21 +303,21 @@ int CnvWblToPs::typedef_exec()
tops.print_text( "", tops.style[tops.ci].text);
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0) {
sprintf( txt, "Author %s", ctx->rw->doc_author);
sprintf( txt, "%s %s", Lng::translate("Author"), ctx->rw->doc_author);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0) {
sprintf( txt, "Version %s", ctx->rw->doc_version);
sprintf( txt, "%s %s", Lng::translate("Version"), ctx->rw->doc_version);
tops.print_text( txt, tops.style[tops.ci].text);
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_code, "") != 0) {
sprintf( txt, "Code %s", ctx->rw->doc_code);
sprintf( txt, "%s %s", Lng::translate("Code"), ctx->rw->doc_code);
tops.print_text( txt, tops.style[tops.ci].text);
}
tops.print_h2( "Description");
tops.print_h2( Lng::translate("Description"));
if ( ctx->rw->doc_fresh) {
for ( i = 0; i < ctx->rw->doc_cnt; i++) {
CnvCtx::remove_spaces( ctx->rw->doc_text[i], txt);
......@@ -361,9 +386,13 @@ int CnvWblToPs::bit_exec()
int i;
char *s;
char txt[200];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->typedef_name, ctx->rw->bit_name);
tops.print_h3( ctx->rw->bit_name);
sprintf( txt, "Type %s", ctx->rw->bit_type);
sprintf( txt, "%s %s", Lng::translate("Type"), ctx->rw->bit_type);
tops.print_text( txt, tops.style[tops.ci].boldtext);
sprintf( txt, "Value %d", ctx->rw->bit_value);
......
......@@ -12,7 +12,7 @@ extern "C" {
#include "pwr.h"
#include "co_cdh.h"
}
#include "co_lng.h"
int CnvWblToXtthelp::init( char *first)
{
......@@ -58,6 +58,10 @@ int CnvWblToXtthelp::class_exec()
char link_ref[80];
char *s;
char txt[256];
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->class_name, 0);
strcpy( full_class_name, ctx->rw->volume_name);
strcat( full_class_name, ":");
......@@ -75,23 +79,27 @@ int CnvWblToXtthelp::class_exec()
xtthelp_in_topic = 1;
fp_tmp <<
"<TOPIC> " << ctx->rw->class_name << endl <<
"Class " << full_class_name << endl <<
Lng::translate("Class") << " " << full_class_name << endl <<
"<H1>" << ctx->rw->class_name << endl << endl;
if ( !lng_sts)
fp_tmp <<
"(" << Lng::translate( "English text not available") << ")" << endl << endl;
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_author, "") != 0)
{
fp_tmp <<
"<B>Author<T>" << ctx->rw->doc_author << endl;
"<B>" << Lng::translate("Author") << "<T>" << ctx->rw->doc_author << endl;
}
if ( ctx->rw->doc_fresh && strcmp( ctx->rw->doc_version, "") != 0)
{
fp_tmp <<
"<B>Version<T>" << ctx->rw->doc_version << endl;
"<B>" << Lng::translate("Version") << "<T>" << ctx->rw->doc_version << endl;
}
fp_tmp <<
"<H1>Description" << endl;
"<H1>"<< Lng::translate("Description") << endl;
if ( ctx->rw->doc_fresh) {
......@@ -160,6 +168,10 @@ int CnvWblToXtthelp::attribute_exec()
{
int i;
char *s;
int lng_sts = 1;
if ( Lng::current() != lng_eLanguage_en_us)
lng_sts = ctx->rw->read_lng( ctx->rw->class_name, ctx->rw->attr_name);
fp_tmp <<
endl <<
......
......@@ -102,7 +102,7 @@ int main( int argc, char *argv[])
int xtthelp_to_xml = 0;
int xtthelp_to_ps = 0;
if ( argc < 2 || argc > 8) {
if ( argc < 2 || argc > 9) {
usage();
exit(0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment