* update for localization
Sylvestre Ledru [Fri, 4 Jan 2008 09:59:11 +0000 (09:59 +0000)]
* new function added getdefaultlanguage
* setlanguage should work better
* update of documentation

scilab/modules/localization/Makefile.am
scilab/modules/localization/Makefile.in
scilab/modules/localization/help/en_US/getlanguage.xml
scilab/modules/localization/includes/gw_localization.h
scilab/modules/localization/sci_gateway/c/gw_localization.c
scilab/modules/localization/sci_gateway/c/sci_getdefaultlanguage.c [new file with mode: 0644]
scilab/modules/localization/sci_gateway/c/sci_getlanguage.c
scilab/modules/localization/sci_gateway/c/sci_setlanguage.c
scilab/modules/localization/sci_gateway/localization_gateway.xml

index 6e42ac6..807cc08 100644 (file)
@@ -1,6 +1,6 @@
 ##########
 ### Sylvestre Ledru <sylvestre.ledru@inria.fr>
-### INRIA - Scilab 2006/2007
+### INRIA - Scilab 2006/2007/2008
 ##########
 
 LOCALIZATION_C_SOURCES = \
@@ -17,6 +17,7 @@ endif
 GATEWAY_C_SOURCES = sci_gateway/c/gw_localization.c \
 sci_gateway/c/sci_gettext.c \
 sci_gateway/c/sci_setlanguage.c \
+sci_gateway/c/sci_getdefaultlanguage.c \
 sci_gateway/c/sci_getlanguage.c
 
 #sci_gateway/c/sci_getlanguagealias.c \
index fe45b8d..c46fdde 100644 (file)
@@ -16,7 +16,7 @@
 
 ##########
 ### Sylvestre Ledru <sylvestre.ledru@inria.fr>
-### INRIA - Scilab 2006/2007
+### INRIA - Scilab 2006/2007/2008
 ##########
 
 ##########
@@ -94,6 +94,7 @@ am__objects_1 = libscilocalization_la-InitializeLocalization.lo \
 am__objects_2 = libscilocalization_la-gw_localization.lo \
        libscilocalization_la-sci_gettext.lo \
        libscilocalization_la-sci_setlanguage.lo \
+       libscilocalization_la-sci_getdefaultlanguage.lo \
        libscilocalization_la-sci_getlanguage.lo
 am_libscilocalization_la_OBJECTS = $(am__objects_1) $(am__objects_2)
 libscilocalization_la_OBJECTS = $(am_libscilocalization_la_OBJECTS)
@@ -309,6 +310,7 @@ src/c/loadsavelanguage.c
 GATEWAY_C_SOURCES = sci_gateway/c/gw_localization.c \
 sci_gateway/c/sci_gettext.c \
 sci_gateway/c/sci_setlanguage.c \
+sci_gateway/c/sci_getdefaultlanguage.c \
 sci_gateway/c/sci_getlanguage.c
 
 
@@ -483,6 +485,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-InitializeLocalization.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-gw_localization.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-loadsavelanguage.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-sci_getdefaultlanguage.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-sci_getlanguage.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-sci_gettext.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-sci_setlanguage.Plo@am__quote@
@@ -551,6 +554,13 @@ libscilocalization_la-sci_setlanguage.lo: sci_gateway/c/sci_setlanguage.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -c -o libscilocalization_la-sci_setlanguage.lo `test -f 'sci_gateway/c/sci_setlanguage.c' || echo '$(srcdir)/'`sci_gateway/c/sci_setlanguage.c
 
+libscilocalization_la-sci_getdefaultlanguage.lo: sci_gateway/c/sci_getdefaultlanguage.c
+@am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -MT libscilocalization_la-sci_getdefaultlanguage.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-sci_getdefaultlanguage.Tpo -c -o libscilocalization_la-sci_getdefaultlanguage.lo `test -f 'sci_gateway/c/sci_getdefaultlanguage.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getdefaultlanguage.c
+@am__fastdepCC_TRUE@   mv -f $(DEPDIR)/libscilocalization_la-sci_getdefaultlanguage.Tpo $(DEPDIR)/libscilocalization_la-sci_getdefaultlanguage.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='sci_gateway/c/sci_getdefaultlanguage.c' object='libscilocalization_la-sci_getdefaultlanguage.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -c -o libscilocalization_la-sci_getdefaultlanguage.lo `test -f 'sci_gateway/c/sci_getdefaultlanguage.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getdefaultlanguage.c
+
 libscilocalization_la-sci_getlanguage.lo: sci_gateway/c/sci_getlanguage.c
 @am__fastdepCC_TRUE@   $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -MT libscilocalization_la-sci_getlanguage.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-sci_getlanguage.Tpo -c -o libscilocalization_la-sci_getlanguage.lo `test -f 'sci_gateway/c/sci_getlanguage.c' || echo '$(srcdir)/'`sci_gateway/c/sci_getlanguage.c
 @am__fastdepCC_TRUE@   mv -f $(DEPDIR)/libscilocalization_la-sci_getlanguage.Tpo $(DEPDIR)/libscilocalization_la-sci_getlanguage.Plo
index d392905..17d8cc4 100644 (file)
@@ -9,7 +9,7 @@
 
   <DATE>$LastChangedDate: 2007-04-22 18:33:00 +0200 (dim., 22 avr. 2007) $</DATE>
 
-  <SHORT_DESCRIPTION name="getlanguage">getlanguagestable() returns current language used by Scilab.</SHORT_DESCRIPTION>
+  <SHORT_DESCRIPTION name="getlanguage">getlanguage() returns current language used by Scilab.</SHORT_DESCRIPTION>
 
   <CALLING_SEQUENCE>
     <CALLING_SEQUENCE_ITEM>getlanguage()</CALLING_SEQUENCE_ITEM>
@@ -34,5 +34,6 @@ getlanguage()
 
   <AUTHORS>
     <AUTHORS_ITEM>A.C.</AUTHORS_ITEM>
+    <AUTHORS_ITEM>Sylvestre Ledru</AUTHORS_ITEM>
   </AUTHORS>
 </MAN>
\ No newline at end of file
index f39c635..8ec7002 100644 (file)
@@ -12,6 +12,7 @@ int C2F(gw_localization)(void);
 /*--------------------------------------------------------------------------*/ 
 int C2F(sci_setlanguage) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_getlanguage) _PARAMS((char *fname,unsigned long fname_len));
+int C2F(sci_getdefaultlanguage) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_gettext) _PARAMS((char *fname,unsigned long fname_len));
 /*int C2F(sci_getlanguagealias) _PARAMS((char *fname,unsigned long fname_len));
 int C2F(sci_getlanguagestable) _PARAMS((char *fname,unsigned long fname_len));
index fe0117d..9717908 100644 (file)
@@ -11,6 +11,7 @@ static gw_generic_table Tab[]=
 {
                {C2F(sci_setlanguage),"setlanguage"},
                {C2F(sci_getlanguage),"getlanguage"},
+               {C2F(sci_getdefaultlanguage),"getdefaultlanguage"},
                {C2F(sci_gettext),"gettext"},
                {C2F(sci_gettext),"_"}
 };
diff --git a/scilab/modules/localization/sci_gateway/c/sci_getdefaultlanguage.c b/scilab/modules/localization/sci_gateway/c/sci_getdefaultlanguage.c
new file mode 100644 (file)
index 0000000..c2f5a62
--- /dev/null
@@ -0,0 +1,27 @@
+/*--------------------------------------------------------------------------*/
+/* INRIA 2008 */
+/* @author Sylvestre LEDRU */
+/*--------------------------------------------------------------------------*/
+#include "sci_getlanguage.h"
+#include "defaultlanguage.h"
+#include "Scierror.h"
+#include "MALLOC.h"
+/*--------------------------------------------------------------------------*/
+int C2F(sci_getdefaultlanguage) _PARAMS((char *fname,unsigned long fname_len))
+{
+       static int l1,n1,m1;
+       char *Output=NULL;
+
+       CheckRhs(0,0);
+       CheckLhs(0,1);
+
+       Output=SCILABDEFAULTLANGUAGE;
+
+       n1=1;
+       CreateVarFromPtr( Rhs+1,STRING_DATATYPE,(m1=(int)strlen(Output), &m1),&n1,&Output);
+       LhsVar(1) = Rhs+1;
+       C2F(putlhsvar)();
+
+       return 0;
+}
+/*--------------------------------------------------------------------------*/
index 1937203..ae1a402 100644 (file)
@@ -1,10 +1,9 @@
 /*--------------------------------------------------------------------------*/
-/* INRIA 2007 */
-/* Allan CORNET */
+/* INRIA 2008 */
+/* @author Sylvestre LEDRU */
 /*--------------------------------------------------------------------------*/
 #include "sci_getlanguage.h"
 #include "setgetlanguage.h"
-#include "defaultlanguage.h"
 #include "Scierror.h"
 #include "MALLOC.h"
 /*--------------------------------------------------------------------------*/
@@ -13,38 +12,10 @@ int C2F(sci_getlanguage) _PARAMS((char *fname,unsigned long fname_len))
        static int l1,n1,m1;
        char *Output=NULL;
 
-       CheckRhs(0,1);
+       CheckRhs(0,0);
        CheckLhs(0,1);
 
-       if (Rhs == 1)
-       {
-               if (GetType(1) == sci_strings)
-               {
-                       char *param=NULL;
-
-                       GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
-                       param=cstk(l1);
-
-                       if (strcmp(param,"LANGUAGE_DEFAULT")==0)
-                       {
-                         Output=SCILABDEFAULTLANGUAGE;
-                       }
-                       else
-                       {
-                               Scierror(999,"invalid parameter. see 'help getlanguage'.\n\n");
-                               return 0;
-                       }
-               }
-               else
-               {
-                       Scierror(999,"invalid parameter. see 'help getlanguage'.\n\n");
-                       return 0;
-               }
-       }
-       else
-       {
-               Output=getlanguage();
-       }
+       Output=getlanguage();
 
        n1=1;
        CreateVarFromPtr( Rhs+1,STRING_DATATYPE,(m1=(int)strlen(Output), &m1),&n1,&Output);
index 85a49ed..09881c3 100644 (file)
@@ -26,7 +26,7 @@ int C2F(sci_setlanguage) _PARAMS((char *fname,unsigned long fname_len))
 
                GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
                param=cstk(l1);
-
+               /* Convert small code to long code fr => fr_FR */
                newlanguage=convertlanguagealias(param);
 
                if ( LanguageIsOK(param) && (newlanguage == NULL) )
@@ -60,9 +60,10 @@ int C2F(sci_setlanguage) _PARAMS((char *fname,unsigned long fname_len))
                {
                        if (getWarningMode())
                        {
-                               sciprint(_("\nUnsupported language \"%s\".\n"),param);
-                               sciprint(_("Choosing default language : \"%s\".\n\n"),SCILABDEFAULTLANGUAGE);
+                               sciprint(_("Unsupported language '%s'.\n"),param);
+                               sciprint(_("Switching to default language : '%s'.\n"),SCILABDEFAULTLANGUAGE);   
                        }
+                       setlanguage(SCILABDEFAULTLANGUAGE,TRUE,TRUE);
 
                        CreateVar(Rhs+1,MATRIX_OF_BOOLEAN_DATATYPE, &n1,&n1,&l1);
                        *istk(l1)=(int)(FALSE);
@@ -72,7 +73,7 @@ int C2F(sci_setlanguage) _PARAMS((char *fname,unsigned long fname_len))
        }
        else
        {
-               Scierror(999,_("%s: Wrong type for input argument: String expected.\n"),fname);
+               Scierror(999,_("%s: Wrong type for first input argument: String expected.\n"),fname);
                return 0;
        }
 
index 06872b3..d3c892a 100644 (file)
 
 <PRIMITIVE gatewayId="50" primitiveId="1" primitiveName="setlanguage" />
 <PRIMITIVE gatewayId="50" primitiveId="2" primitiveName="getlanguage" />
-<PRIMITIVE gatewayId="50" primitiveId="3" primitiveName="gettext" />
-<PRIMITIVE gatewayId="50" primitiveId="3" primitiveName="_" />
+<PRIMITIVE gatewayId="50" primitiveId="3" primitiveName="getdefaultlanguage" />
+<PRIMITIVE gatewayId="50" primitiveId="4" primitiveName="gettext" />
+<PRIMITIVE gatewayId="50" primitiveId="5" primitiveName="_" />
+
 
 <!--<PRIMITIVE gatewayId="50" primitiveId="3" primitiveName="getlanguagealias" />
 <PRIMITIVE gatewayId="50" primitiveId="4" primitiveName="getlanguagestable" />