Ignore:
Timestamp:
Oct 1, 2010, 1:41:53 AM (14 years ago)
Author:
djay
Message:

Make ZOO Kernel able to speak the natural language you teach him by using gettext tools for creating translation files. Add basic french translation .po files as current messages.po. Gettext Domains used are zoo-kernel and zoo-services.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/service_internal.c

    r33 r34  
    2525#include "service_internal.h"
    2626
     27void *addLangAttr(xmlNodePtr n,maps *m){
     28  map *tmpLmap=getMapFromMaps(m,"main","language");
     29  if(tmpLmap!=NULL)
     30    xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST tmpLmap->value);
     31  else
     32    xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en-US");
     33}
     34
    2735/* Converts a hex character to its integer value */
    2836char from_hex(char ch) {
     
    281289  xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsGetCapabilities_response.xsd");
    282290  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
     291  addLangAttr(n,m);
    283292 
    284293  if(toto1!=NULL){
     
    512521          xmlAddChild(nc2,nc4);
    513522          xmlAddChild(nc1,nc2);
    514           xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST buff);
    515523          dcount++;
    516524        }
     
    590598  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
    591599  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
    592   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
     600  addLangAttr(n,m);
    593601
    594602  xmlDocSetRootElement(doc, n);
     
    954962  xmlNewProp(n,BAD_CAST "service",BAD_CAST "WPS");
    955963  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.0.0");
    956   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
     964  addLangAttr(n,m);
     965
    957966  char tmp[256];
    958967  char url[1024];
     
    10461055  case SERVICE_SUCCEEDED:
    10471056    nc1 = xmlNewNode(ns, BAD_CAST "ProcessSucceeded");
    1048     sprintf(sMsg,"Service \"%s\" run successfully.",serv->name);
     1057    sprintf(sMsg,_("Service \"%s\" run successfully."),serv->name);
    10491058    nc3=xmlNewText(BAD_CAST sMsg);
    10501059    xmlAddChild(nc1,nc3);
     
    10541063    tmpStatus=getMapFromMaps(m,"lenv","status");
    10551064    xmlNewProp(nc1,BAD_CAST "percentCompleted",BAD_CAST tmpStatus->value);
    1056     sprintf(sMsg,"ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service.",serv->name);
     1065    sprintf(sMsg,_("ZOO Service \"%s\" is currently running. Please, reload this document to get the up-to-date status of the Service."),serv->name);
    10571066    nc3=xmlNewText(BAD_CAST sMsg);
    10581067    xmlAddChild(nc1,nc3);
     
    10601069  case SERVICE_ACCEPTED:
    10611070    nc1 = xmlNewNode(ns, BAD_CAST "ProcessAccepted");
    1062     sprintf(sMsg,"Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document.",serv->name);
     1071    sprintf(sMsg,_("Service \"%s\" was accepted by the ZOO Kernel and it run as a background task. Please consult the statusLocation attribtue providen in this document to get the up-to-date document."),serv->name);
    10631072    nc3=xmlNewText(BAD_CAST sMsg);
    10641073    xmlAddChild(nc1,nc3);
     
    10771086      addToMap(errorMap,"text",te->value);
    10781087    else
    1079       addToMap(errorMap,"text","No more information available");
     1088      addToMap(errorMap,"text",_("No more information available"));
    10801089    nc3=createExceptionReportNode(m,errorMap,0);
    10811090    xmlAddChild(nc1,nc3);
    10821091    break;
    10831092  default :
    1084     printf("error code not know : %i\n",status);
     1093    printf(_("error code not know : %i\n"),status);
    10851094    //exit(1);
    10861095    break;
     
    12501259  // Extract Title required to be first element in the ZCFG file !
    12511260  nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);
    1252   nc3=xmlNewText(BAD_CAST tmp->value);
     1261  nc3=xmlNewText(BAD_CAST _ss(tmp->value));
    12531262  xmlAddChild(nc2,nc3); 
    12541263  xmlAddChild(nc1,nc2);
     
    12561265  tmp=tmp->next;
    12571266  nc2=xmlNewNode(ns_ows, BAD_CAST tmp->name);
    1258   nc3=xmlNewText(BAD_CAST tmp->value);
     1267  nc3=xmlNewText(BAD_CAST _ss(tmp->value));
    12591268  xmlAddChild(nc2,nc3); 
    12601269  xmlAddChild(nc1,nc2);
     
    13521361    if(tmp1!=NULL){
    13531362      nc2 = xmlNewNode(ns_ows, BAD_CAST tmp2[j]);
    1354       xmlAddChild(nc2,xmlNewText(BAD_CAST tmp1->value));
     1363      fprintf(stderr,"[%s] \n[%s]\n",tmp1->value,_ss(tmp1->value));
     1364      xmlAddChild(nc2,xmlNewText(BAD_CAST _ss(tmp1->value)));
    13551365      xmlAddChild(root,nc2);
    13561366    }
     
    13891399  xmlDocPtr doc;
    13901400  xmlChar *xmlbuff;
    1391   xmlNsPtr ns,ns_ows,ns_xlink,ns_xsi;
    1392   xmlNodePtr n,nc,nc1,nc2;
     1401  xmlNodePtr n;
    13931402
    13941403  doc = xmlNewDoc(BAD_CAST "1.0");
     
    14051414  }else
    14061415    printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
    1407 
    1408   ns=xmlNewNs(NULL,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    1409   n = xmlNewNode(ns, BAD_CAST "ExceptionReport"); 
    1410   ns_ows=xmlNewNs(n,BAD_CAST "http://www.opengis.net/ows/1.1",BAD_CAST "ows");
    1411   ns_xlink=xmlNewNs(n,BAD_CAST "http://www.w3.org/1999/xlink",BAD_CAST "xlink");
    1412   ns_xsi=xmlNewNs(n,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
    1413   xmlNewProp(n,BAD_CAST "xsi:schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    1414   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
    1415   xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
    1416 
    1417   nc = xmlNewNode(ns, BAD_CAST "Exception"); 
    1418 
    1419   map* tmp=getMap(s,"code");
    1420   if(tmp!=NULL)
    1421     xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST tmp->value);
    1422   else
    1423     xmlNewProp(nc,BAD_CAST "exceptionCode",BAD_CAST "NoApplicableCode");
    1424 
    1425   tmp=getMap(s,"text");
    1426   nc1 = xmlNewNode(ns, BAD_CAST "ExceptionText");
    1427   nc2=NULL;
    1428   if(tmp!=NULL){
    1429     xmlNodeSetContent(nc1, BAD_CAST tmp->value);
    1430   }
    1431   else{
    1432     xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
    1433   }
    1434   xmlAddChild(nc,nc1);
    1435   xmlAddChild(n,nc);
     1416  n=createExceptionReportNode(m,s,1);
    14361417  xmlDocSetRootElement(doc, n);
    1437 
    14381418  xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, encoding, 1);
    14391419  printf("%s",xmlbuff);
     
    14411421  xmlFreeDoc(doc);
    14421422  xmlFree(xmlbuff);
    1443   xmlFreeNs(ns);
    14441423  xmlCleanupParser();
    14451424}
     
    14651444    xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd");
    14661445  }
    1467   xmlNewProp(n,BAD_CAST "xml:lang",BAD_CAST "en");
     1446  addLangAttr(n,m);
    14681447  xmlNewProp(n,BAD_CAST "version",BAD_CAST "1.1.0");
    14691448 
     
    14831462  }
    14841463  else{
    1485     xmlNodeSetContent(nc1, BAD_CAST "No debug message available");
     1464    xmlNodeSetContent(nc1, BAD_CAST _("No debug message available"));
    14861465  }
    14871466  xmlAddChild(nc,nc1);
     
    15441523      toto=getMap(request_outputs->content,"value");
    15451524      if(toto==NULL){
    1546         map * errormap = createMap("text","Unable to fetch any result");
     1525        map * errormap = createMap("text",_("Unable to fetch any result"));
    15471526        addToMap(errormap,"code", "InternalError");
    15481527        printExceptionReportResponse(m,errormap);
     
    15851564      lenv=getMapFromMaps(m,"lenv","message");
    15861565      if(lenv!=NULL)
    1587         sprintf(tmp,"Unable to run the Service. The message returned back by the Service was the following : %s",lenv->value);
     1566        sprintf(tmp,_("Unable to run the Service. The message returned back by the Service was the following : %s"),lenv->value);
    15881567      else
    1589         sprintf(tmp,"Unable to run the Service. No more information was returned back by the Service.");
     1568        sprintf(tmp,_("Unable to run the Service. No more information was returned back by the Service."));
    15901569      errormap = createMap("text",tmp);     
    15911570      addToMap(errormap,"code", "InternalError");
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png