Changeset 376


Ignore:
Timestamp:
Nov 3, 2012, 3:07:43 AM (12 years ago)
Author:
djay
Message:

Add _ method to the zoo Python module to enable translation from zoo-services textdomain. Add gettextPath in the main section of the main.cfg to set the directory to search for language files.

Location:
trunk/zoo-project/zoo-kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal.h

    r375 r376  
    5959#include <openssl/buffer.h>
    6060
    61 //#include "cgic.h"
     61#include "cgic.h"
    6262#include "ulinet.h"
    6363
  • trunk/zoo-project/zoo-kernel/service_internal_python.c

    r368 r376  
    2828
    2929PyMethodDef zooMethods[] = {
     30  {"_", PythonTranslate, METH_VARARGS, "Translate a string using the zoo-services textdomain."},
    3031  {"update_status", PythonUpdateStatus, METH_VARARGS, "Update status percentage of a running process."},
    3132  {NULL, NULL, 0, NULL} /* tempt not the blade, all fear the sentinel */
     
    418419
    419420PyObject*
     421PythonTranslate(PyObject* self, PyObject* args)
     422{
     423  char *str;
     424  if (!PyArg_ParseTuple(args, "s", &str)){
     425#ifdef DEBUG
     426    fprintf(stderr,"Incorrect arguments to update status function");
     427#endif
     428    return NULL;
     429  }
     430  return PyString_FromString(_ss(str));
     431}
     432
     433PyObject*
    420434PythonUpdateStatus(PyObject* self, PyObject* args)
    421435{
  • trunk/zoo-project/zoo-kernel/service_internal_python.h

    r368 r376  
    4545int zoo_python_support(maps**,map*,service*,maps**,maps**);
    4646
     47PyObject* PythonTranslate(PyObject*, PyObject*);
    4748PyObject* PythonUpdateStatus(PyObject*, PyObject*);
    4849
  • trunk/zoo-project/zoo-kernel/zoo_loader.c

    r375 r376  
    7878  fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0);
    7979  fprintf (stderr, "Request: %s\n", cgiQueryString);
     80  fflush(stderr);
    8081#endif
    8182
     
    8586  if(strncmp(cgiContentType,"text/xml",8)==0 ||
    8687     strncasecmp(cgiRequestMethod,"post",4)==0){
    87     //fprintf(stderr,"length %d\n",cgiContentLength);
    8888    if(cgiContentLength==NULL){
    8989       cgiContentLength=0;
     
    104104         }
    105105       }
    106        if(res==NULL){
     106       if(res==NULL && (strQuery==NULL || strlen(strQuery)==0)){
    107107         return errorException(NULL,"ZOO-Kernel failed to process your request cause the request was emtpty.","InternalError");
    108        }else
    109          tmpMap=createMap("request",res);
     108       }else{
     109         if(strQuery==NULL || strlen(strQuery)==0)
     110           tmpMap=createMap("request",res);
     111       }
    110112    }else{
    111113      char *buffer=new char[cgiContentLength+1];
     
    113115        buffer[cgiContentLength]=0;
    114116        tmpMap=createMap("request",buffer);
    115         //fprintf(stderr,"%s\n",tmpMap->value);
    116117      }else{
    117118        buffer[0]=0;
     
    133134            free(tmp);
    134135          }
    135          
    136           sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
    137136          free(tmpValueFinal);
    138137#ifdef DEBUG
     
    321320  }
    322321
    323 
    324322  if(strncasecmp(cgiContentType,"multipart/form-data",19)==0){
    325       map* tmp=getMap(tmpMap,"dataInputs");
    326       if(tmp!=NULL){
    327         addToMap(tmpMap,"dataInputs",strstr(strQuery,"dataInputs=")+11);
    328       }
    329     }
     323    map* tmp=getMap(tmpMap,"dataInputs");
     324    if(tmp!=NULL){
     325      addToMap(tmpMap,"dataInputs",strstr(strQuery,"dataInputs=")+11);
     326    }
     327  }
    330328
    331329  runRequest(tmpMap);
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r375 r376  
    2828extern "C" int crlex();
    2929
     30#include "cgic.h"
     31
    3032extern "C" {
    3133#include <libxml/tree.h>
     
    3638}
    3739
    38 #include "cgic.h"
    3940#include "ulinet.h"
    4041
     
    108109
    109110#define _(String) dgettext ("zoo-kernel",String)
     111#define __(String) dgettext ("zoo-service",String)
    110112
    111113
     
    541543#endif
    542544
    543   bindtextdomain ("zoo-kernel","/usr/share/locale/");
    544   bindtextdomain ("zoo-services","/usr/share/locale/");
     545  map *getPath=getMapFromMaps(m,"main","gettextPath");
     546  if(getPath!=NULL){
     547    bindtextdomain ("zoo-kernel",getPath->value);
     548    bindtextdomain ("zoo-services",getPath->value);   
     549  }else{
     550    bindtextdomain ("zoo-kernel","/usr/share/locale/");
     551    bindtextdomain ("zoo-services","/usr/share/locale/");
     552  }
    545553
    546554  /**
     
    554562        fstde = freopen(fstdem->value, "a+", stderr) ;
    555563
    556   if((r_inputs=getMap(request_inputs,"language"))!=NULL){
     564  r_inputs=getMap(request_inputs,"language");
     565  if(r_inputs==NULL)
     566    r_inputs=getMapFromMaps(m,"main","language");
     567  if(r_inputs!=NULL){
    557568    char *tmp=strdup(r_inputs->value);
     569    setMapInMaps(m,"main","language",tmp);
    558570    translateChar(tmp,'-','_');
    559571    setlocale (LC_ALL, tmp);
     572#ifdef WIN32
     573    char tmp1[12];
     574    sprintf(tmp1,"LC_ALL=%s",tmp);
     575    putenv(tmp1);
     576#endif
    560577    free(tmp);
    561     setMapInMaps(m,"main","language",r_inputs->value);
    562578  }
    563579  else{
    564580    setlocale (LC_ALL, "en_US");
     581#ifdef WIN32
     582    char tmp1[12];
     583    sprintf(tmp1,"LC_ALL=en_US");
     584    putenv(tmp1);
     585#endif
    565586    setMapInMaps(m,"main","language","en-US");
    566587  }
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