add management of multiple domains in localization. 48/12048/8
Antoine ELIAS [Tue, 16 Jul 2013 17:27:35 +0000 (19:27 +0200)]
add function addlocalizationdomain and add optional parameter to gettext

Change-Id: I298b4c549abc63e52b36f17642df5889e9af754d

23 files changed:
SEP/SEP_103_addlocalizationdomain.odt [new file with mode: 0644]
scilab/CHANGES_5.5.X
scilab/modules/localization/Makefile.am
scilab/modules/localization/Makefile.in
scilab/modules/localization/help/en_US/addlocalizationdomain.xml [new file with mode: 0644]
scilab/modules/localization/help/en_US/gettext.xml
scilab/modules/localization/includes/gw_localization.h
scilab/modules/localization/includes/localization.h
scilab/modules/localization/sci_gateway/c/gw_localization.c
scilab/modules/localization/sci_gateway/c/sci_addlocalizationdomain.c [new file with mode: 0644]
scilab/modules/localization/sci_gateway/c/sci_dgettext.c [deleted file]
scilab/modules/localization/sci_gateway/c/sci_gettext.c
scilab/modules/localization/sci_gateway/localization_gateway.xml
scilab/modules/localization/src/localization.vcxproj
scilab/modules/localization/src/localization.vcxproj.filters
scilab/modules/localization/tests/unit_tests/addlocalizationdomain.dia.ref [new file with mode: 0644]
scilab/modules/localization/tests/unit_tests/addlocalizationdomain.tst [new file with mode: 0644]
scilab/modules/localization/tests/unit_tests/gettext.dia.ref
scilab/modules/localization/tests/unit_tests/gettext.tst
scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.mo [new file with mode: 0644]
scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.po [new file with mode: 0644]
scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.mo [new file with mode: 0644]
scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.po [new file with mode: 0644]

diff --git a/SEP/SEP_103_addlocalizationdomain.odt b/SEP/SEP_103_addlocalizationdomain.odt
new file mode 100644 (file)
index 0000000..967f82b
Binary files /dev/null and b/SEP/SEP_103_addlocalizationdomain.odt differ
index d0fc865..559e537 100644 (file)
@@ -48,6 +48,11 @@ BDF methods with direct and preconditioned Krylov linear solvers, based on ODEPA
  - A user can now plot variables from the variable browser (already available in
   editvar).
 
+* Localization:
+ - Multiple domains in localization managed.
+ - Function addlocalizationdomain added.
+ - Optional parameter added to gettext to manage domains.
+
 * Windows Solution updated to Visual Studio 2012.
 
 * -keepconsole option added for Scilab Windows to facilitate debugging.
index 63b264b..ef017e3 100644 (file)
@@ -27,11 +27,12 @@ endif
 
 GATEWAY_C_SOURCES = sci_gateway/c/gw_localization.c \
 sci_gateway/c/sci_gettext.c \
-sci_gateway/c/sci_dgettext.c \
 sci_gateway/c/sci_setlanguage.c \
 sci_gateway/c/sci_getdefaultlanguage.c \
 sci_gateway/c/sci_getlanguage.c \
-sci_gateway/c/sci_setdefaultlanguage.c
+sci_gateway/c/sci_setdefaultlanguage.c \
+sci_gateway/c/sci_addlocalizationdomain.c
+
 
 libscilocalization_la_CPPFLAGS = $(JAVA_JNI_INCLUDE) \
                                -I$(srcdir)/includes/ \
index c00192c..3bbd403 100644 (file)
@@ -209,11 +209,11 @@ libscilocalization_algo_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
 libscilocalization_la_DEPENDENCIES = libscilocalization-algo.la
 am__objects_4 = libscilocalization_la-gw_localization.lo \
        libscilocalization_la-sci_gettext.lo \
-       libscilocalization_la-sci_dgettext.lo \
        libscilocalization_la-sci_setlanguage.lo \
        libscilocalization_la-sci_getdefaultlanguage.lo \
        libscilocalization_la-sci_getlanguage.lo \
-       libscilocalization_la-sci_setdefaultlanguage.lo
+       libscilocalization_la-sci_setdefaultlanguage.lo \
+       libscilocalization_la-sci_addlocalizationdomain.lo
 am_libscilocalization_la_OBJECTS = $(am__objects_4)
 libscilocalization_la_OBJECTS = $(am_libscilocalization_la_OBJECTS)
 libscilocalization_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
@@ -560,11 +560,11 @@ LOCALIZATION_C_SOURCES = src/c/InitializeLocalization.c \
        $(am__append_1) $(am__append_2)
 GATEWAY_C_SOURCES = sci_gateway/c/gw_localization.c \
 sci_gateway/c/sci_gettext.c \
-sci_gateway/c/sci_dgettext.c \
 sci_gateway/c/sci_setlanguage.c \
 sci_gateway/c/sci_getdefaultlanguage.c \
 sci_gateway/c/sci_getlanguage.c \
-sci_gateway/c/sci_setdefaultlanguage.c
+sci_gateway/c/sci_setdefaultlanguage.c \
+sci_gateway/c/sci_addlocalizationdomain.c
 
 libscilocalization_la_CPPFLAGS = $(JAVA_JNI_INCLUDE) \
                                -I$(srcdir)/includes/ \
@@ -798,7 +798,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_algo_la-setdefaultlanguage_wrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_algo_la-setgetlanguage.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-sci_dgettext.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-sci_addlocalizationdomain.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@
@@ -903,13 +903,6 @@ libscilocalization_la-sci_gettext.lo: sci_gateway/c/sci_gettext.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -c -o libscilocalization_la-sci_gettext.lo `test -f 'sci_gateway/c/sci_gettext.c' || echo '$(srcdir)/'`sci_gateway/c/sci_gettext.c
 
-libscilocalization_la-sci_dgettext.lo: sci_gateway/c/sci_dgettext.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -MT libscilocalization_la-sci_dgettext.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-sci_dgettext.Tpo -c -o libscilocalization_la-sci_dgettext.lo `test -f 'sci_gateway/c/sci_dgettext.c' || echo '$(srcdir)/'`sci_gateway/c/sci_dgettext.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscilocalization_la-sci_dgettext.Tpo $(DEPDIR)/libscilocalization_la-sci_dgettext.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_dgettext.c' object='libscilocalization_la-sci_dgettext.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -c -o libscilocalization_la-sci_dgettext.lo `test -f 'sci_gateway/c/sci_dgettext.c' || echo '$(srcdir)/'`sci_gateway/c/sci_dgettext.c
-
 libscilocalization_la-sci_setlanguage.lo: sci_gateway/c/sci_setlanguage.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -MT libscilocalization_la-sci_setlanguage.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-sci_setlanguage.Tpo -c -o libscilocalization_la-sci_setlanguage.lo `test -f 'sci_gateway/c/sci_setlanguage.c' || echo '$(srcdir)/'`sci_gateway/c/sci_setlanguage.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscilocalization_la-sci_setlanguage.Tpo $(DEPDIR)/libscilocalization_la-sci_setlanguage.Plo
@@ -938,6 +931,13 @@ libscilocalization_la-sci_setdefaultlanguage.lo: sci_gateway/c/sci_setdefaultlan
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -c -o libscilocalization_la-sci_setdefaultlanguage.lo `test -f 'sci_gateway/c/sci_setdefaultlanguage.c' || echo '$(srcdir)/'`sci_gateway/c/sci_setdefaultlanguage.c
 
+libscilocalization_la-sci_addlocalizationdomain.lo: sci_gateway/c/sci_addlocalizationdomain.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -MT libscilocalization_la-sci_addlocalizationdomain.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-sci_addlocalizationdomain.Tpo -c -o libscilocalization_la-sci_addlocalizationdomain.lo `test -f 'sci_gateway/c/sci_addlocalizationdomain.c' || echo '$(srcdir)/'`sci_gateway/c/sci_addlocalizationdomain.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/libscilocalization_la-sci_addlocalizationdomain.Tpo $(DEPDIR)/libscilocalization_la-sci_addlocalizationdomain.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sci_gateway/c/sci_addlocalizationdomain.c' object='libscilocalization_la-sci_addlocalizationdomain.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscilocalization_la_CPPFLAGS) $(CPPFLAGS) $(libscilocalization_la_CFLAGS) $(CFLAGS) -c -o libscilocalization_la-sci_addlocalizationdomain.lo `test -f 'sci_gateway/c/sci_addlocalizationdomain.c' || echo '$(srcdir)/'`sci_gateway/c/sci_addlocalizationdomain.c
+
 mostlyclean-libtool:
        -rm -f *.lo
 
diff --git a/scilab/modules/localization/help/en_US/addlocalizationdomain.xml b/scilab/modules/localization/help/en_US/addlocalizationdomain.xml
new file mode 100644 (file)
index 0000000..c981740
--- /dev/null
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="addlocalizationdomain">
+    <refnamediv>
+        <refname>addlocalizationdomain</refname>
+        <refpurpose>add a new domain in localization mechanism.</refpurpose>
+    </refnamediv>
+    <refsynopsisdiv>
+        <title>Calling Sequence</title>
+        <synopsis>msg=addlocalizationdomain(domain, path)</synopsis>
+    </refsynopsisdiv>
+    <refsection>
+        <title>Arguments</title>
+        <variablelist>
+            <varlistentry>
+                <term>domain</term>
+                <listitem>
+                    <para>a string, the name of the messages domain</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>path</term>
+                <listitem>
+                    <para>path to the domain files</para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+    </refsection>
+    <refsection>
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+setlanguage("fr_FR");
+gettext("Startup execution:")
+_("Startup execution:")
+addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale")
+gettext("tbx", "%s: something not in Scilab.\n")
+_("tbx", "%s: something not in Scilab.\n")
+ ]]></programlisting>
+    </refsection>
+    <refsection role="see also">
+        <title>See Also</title>
+        <simplelist type="inline">
+            <member>
+                <link linkend="gettext">gettext</link>
+            </member>
+        </simplelist>
+    </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revdescription>addlocalizationdomain function added.</revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
+</refentry>
index ee0f595..536946e 100644 (file)
@@ -3,11 +3,11 @@
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - Allan CORNET
  * Copyright (C) 2007 - INRIA - Sylvestre LEDRU
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
  *
  -->
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
-        <synopsis>msg=gettext(myString)
-            msg=_(myString)
+        <synopsis>msg=gettext([myDomain,] myString)
+            msg=_([myDomain,] myString)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Arguments</title>
         <variablelist>
             <varlistentry>
+                <term>myDomain</term>
+                <listitem>
+                    <para>a string, the name of the messages domain</para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
                 <term>myString</term>
                 <listitem>
                     <para>a string, the message to be translated</para>
             <literal>gettext(myString)</literal> gets the translation of a string <literal>myString</literal> to the current locale in the current domain.
         </para>
         <para>
+            <literal>gettext(myDomain, myString)</literal> gets the translation of a string <literal>myString</literal> to the <literal>myDomain</literal> domain.
+        </para>
+        <para>
             <code>_(myString)</code> is an alias of <code>gettext(myString)</code>.
         </para>
+        <para>
+            <code>_(myDomain, myString)</code> is an alias of <code>gettext(myDomain, myString)</code>.
+        </para>
     </refsection>
     <refsection>
         <title>Examples</title>
         <programlisting role="example"><![CDATA[ 
+setlanguage("fr_FR");
 gettext("Startup execution:")
 _("Startup execution:")
+addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale")
+gettext("tbx", "%s: something not in Scilab.\n")
+_("tbx", "%s: something not in Scilab.\n")
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
             <member>
-                <link linkend="dgettext">dgettext</link>
+                <link linkend="addlocalizationdomain">addlocalizationdomain</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.0</revnumber>
+                <revdescription>Domain management added.</revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 7c7a6f3..52286fb 100644 (file)
@@ -23,9 +23,9 @@ LOCALIZATION_IMPEXP int sci_setlanguage(char *fname, unsigned long fname_len);
 LOCALIZATION_IMPEXP int sci_getlanguage(char *fname, unsigned long fname_len);
 LOCALIZATION_IMPEXP int sci_getdefaultlanguage(char *fname, unsigned long fname_len);
 LOCALIZATION_IMPEXP int sci_gettext(char *fname, unsigned long fname_len);
-LOCALIZATION_IMPEXP int sci_dgettext(char *fname, unsigned long fname_len);
-LOCALIZATION_IMPEXP int sci_dgettextchar(char *fname, unsigned long fname_len);
 LOCALIZATION_IMPEXP int sci_setdefaultlanguage(char *fname, unsigned long fname_len);
+LOCALIZATION_IMPEXP int sci_addlocalizationdomain(char *fname, unsigned long fname_len);
+
 /*--------------------------------------------------------------------------*/
 #endif /*  __GW_LOCALIZATION__ */
 /*--------------------------------------------------------------------------*/
index 47c22f0..43ac189 100644 (file)
@@ -28,6 +28,7 @@ extern "C" {
 
 
 #define _(String)  gettext(String)/** for console message*/
+#define _d(Domain, String)  dgettext(Domain, String)/** for console message*/
 #define _t(String1,String2,n) ngettext (String1,String2,n)
 
 #else
index 9f47e04..1df69bf 100644 (file)
@@ -22,8 +22,9 @@ static gw_generic_table Tab[] =
     {sci_getlanguage, "getlanguage"},
     {sci_getdefaultlanguage, "getdefaultlanguage"},
     {sci_gettext, "gettext"},
-    {sci_dgettext, "dgettext"},
-    {sci_setdefaultlanguage, "setdefaultlanguage"}
+    {sci_gettext, "dgettext"},
+    {sci_setdefaultlanguage, "setdefaultlanguage"},
+    {sci_addlocalizationdomain, "addlocalizationdomain"}
 };
 /*--------------------------------------------------------------------------*/
 int gw_localization(void)
diff --git a/scilab/modules/localization/sci_gateway/c/sci_addlocalizationdomain.c b/scilab/modules/localization/sci_gateway/c/sci_addlocalizationdomain.c
new file mode 100644 (file)
index 0000000..d637407
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+/*--------------------------------------------------------------------------*/
+#include <string.h>
+#include <stdlib.h>
+#include "MALLOC.h"
+#include "localization.h"
+#include "gw_localization.h"
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "strsubst.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include "freeArrayOfString.h"
+#include "expandPathVariable.h"
+
+int sci_addlocalizationdomain(char *fname, unsigned long fname_len)
+{
+    SciErr sciErr;
+    int* piAddr1 = NULL;
+    char* pstDomain = NULL;
+
+    int* piAddr2 = NULL;
+    char* pstPath = NULL;
+    char* expandedPath = NULL;
+
+    char* pstRet = NULL;
+
+    int iRhs = nbInputArgument(pvApiCtx);
+    int iLhs = nbOutputArgument(pvApiCtx);
+
+
+    CheckInputArgument(pvApiCtx, 2, 2);
+    CheckOutputArgument(pvApiCtx, 1, 1);
+
+    //get domain name
+    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
+        return 0;
+    }
+
+    if (isStringType(pvApiCtx, piAddr1) == 0 || isScalar(pvApiCtx, piAddr1) == 0)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), fname, 1);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, piAddr1, &pstDomain))
+    {
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
+    }
+
+    //get domain path
+    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
+        return 0;
+    }
+
+    if (isStringType(pvApiCtx, piAddr2) == 0 || isScalar(pvApiCtx, piAddr2) == 0)
+    {
+        Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), fname, 2);
+        return 0;
+    }
+
+    if (getAllocatedSingleString(pvApiCtx, piAddr2, &pstPath))
+    {
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
+    }
+
+    expandedPath = expandPathVariable(pstPath);
+    pstRet = bindtextdomain(pstDomain, expandedPath);
+
+    freeAllocatedSingleString(pstDomain);
+    freeAllocatedSingleString(pstPath);
+    FREE(expandedPath);
+
+    if (pstRet == NULL)
+    {
+        Scierror(999, _("%s: Unable to add new domain %s.\n"), fname, pstDomain);
+        return 0;
+    }
+
+    if (createScalarBoolean(pvApiCtx, iRhs + 1, 1))
+    {
+        Scierror(999, _("%s: Unable to add new domain %s.\n"), fname, pstDomain);
+        return 0;
+    }
+
+    AssignOutputVariable(pvApiCtx, 1) = iRhs + 1;
+    ReturnArguments(pvApiCtx);
+    return 0;
+}
\ No newline at end of file
diff --git a/scilab/modules/localization/sci_gateway/c/sci_dgettext.c b/scilab/modules/localization/sci_gateway/c/sci_dgettext.c
deleted file mode 100644 (file)
index ae59eae..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2007 - INRIA - Sylvestre LEDRU
-* Copyright (C) 2012 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution.  The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
-*
-*/
-/*--------------------------------------------------------------------------*/
-#include <string.h>
-#include <stdlib.h>
-#include "MALLOC.h"
-#include "localization.h"
-#include "gw_localization.h"
-#include "api_scilab.h"
-#include "Scierror.h"
-#include "strsubst.h"
-#ifdef _MSC_VER
-#include "strdup_windows.h"
-#endif
-#include "freeArrayOfString.h"
-/*--------------------------------------------------------------------------*/
-static char *convertString_dgettext(const char *domain, const char *pStr);
-/*--------------------------------------------------------------------------*/
-int sci_dgettext(char *fname, unsigned long fname_len)
-{
-    SciErr sciErr;
-    int *piAddressVarOne = NULL;
-    int *piAddressVarTwo = NULL;
-
-    CheckRhs(2, 2);
-    CheckLhs(1, 1);
-
-    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-    }
-
-    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 2);
-    }
-
-    if (isStringType(pvApiCtx, piAddressVarOne) && isStringType(pvApiCtx, piAddressVarTwo))
-    {
-        char *domain = NULL;
-
-        if (!isScalar(pvApiCtx, piAddressVarOne))
-        {
-            Scierror(999, "%s: Wrong size for input argument #%d: A string expected.\n", fname, 1);
-            return 0;
-        }
-
-        if (getAllocatedSingleString(pvApiCtx, piAddressVarOne, &domain) == 0)
-        {
-            char **stringsToTranslate = NULL;
-            char **TranslatedStrings = NULL;
-            int m = 0, n = 0;
-            int i = 0;
-
-            if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarTwo, &m, &n, &stringsToTranslate) != 0)
-            {
-                Scierror(999, _("%s: No more memory.\n"), fname);
-                return 0;
-            }
-
-            TranslatedStrings = (char **)MALLOC(sizeof(char*) * (m * n));
-            if (TranslatedStrings == NULL)
-            {
-                freeAllocatedMatrixOfString(m, n, stringsToTranslate);
-                stringsToTranslate = NULL;
-                Scierror(999, _("%s: No more memory.\n"), fname);
-                return 0;
-            }
-
-            for (i = 0; i < m * n; i++)
-            {
-                if (strcmp(stringsToTranslate[i], "") == 0)
-                {
-                    TranslatedStrings[i] = strdup("");
-                }
-                else
-                {
-                    TranslatedStrings[i] = convertString_dgettext(domain, stringsToTranslate[i]);
-                }
-            }
-
-            freeAllocatedMatrixOfString(m, n, stringsToTranslate);
-            stringsToTranslate = NULL;
-
-            sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, m, n, TranslatedStrings);
-            freeArrayOfString(TranslatedStrings, m * n);
-            TranslatedStrings = NULL;
-
-            if (sciErr.iErr)
-            {
-                printError(&sciErr, 0);
-                Scierror(999, _("%s: Memory allocation error.\n"), fname);
-                return 0;
-            }
-
-            LhsVar(1) = Rhs + 1;
-            PutLhsVar();
-        }
-        else
-        {
-            Scierror(999, _("%s: No more memory.\n"), fname);
-            return 0;
-        }
-    }
-    else
-    {
-        if (isStringType(pvApiCtx, piAddressVarOne))
-        {
-            Scierror(999, "%s: Wrong type for input argument #%d: String expected.\n", fname, 2);
-        }
-        else
-        {
-            Scierror(999, "%s: Wrong type for input argument #%d: String expected.\n", fname, 1);
-        }
-    }
-    return 0;
-}
-/*--------------------------------------------------------------------------*/
-static char *convertString_dgettext(const char *domain, const char *pStr)
-{
-    char *pStrConverted = NULL;
-
-    if (pStr)
-    {
-        BOOL revertStrsub = FALSE;
-        char *TranslatedString = NULL;
-        char *tmpStr = NULL;
-        if (strchr(pStr, '\\') != NULL)
-        {
-            char *tmpStr1 = NULL;
-            char *tmpStr2 = NULL;
-            /* There is an \ in the string process to replace */
-
-            /* We always have something from this functions because gettext
-            * is returning the same string if it cannot find it */
-
-            tmpStr1 = strsub((char*)pStr, "\\n", "\n"); /* linefeed */
-            tmpStr2 = strsub(tmpStr1, "\\t", "\t"); /* horizontal tab */
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-
-            tmpStr1 = strsub(tmpStr2, "\\r", "\r"); /* carriage return */
-            if (tmpStr2)
-            {
-                FREE(tmpStr2);
-                tmpStr2 = NULL;
-            }
-
-            tmpStr2 = strsub(tmpStr1, "\\v", "\v"); /* vertical tab */
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-
-            tmpStr1 = strsub(tmpStr2, "\\f", "\f"); /* form feed */
-            if (tmpStr2)
-            {
-                FREE(tmpStr2);
-                tmpStr2 = NULL;
-            }
-
-            tmpStr2 = strsub(tmpStr1, "\\\\", "\\"); /* backslash */
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-
-            tmpStr1 = strsub(tmpStr2, "\\\"", "\""); /* double quote */
-            if (tmpStr2)
-            {
-                FREE(tmpStr2);
-                tmpStr2 = NULL;
-            }
-
-            revertStrsub = TRUE;
-            tmpStr = strdup(tmpStr1);
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-        }
-        else
-        {
-            revertStrsub = FALSE;
-            tmpStr = strdup(pStr);
-        }
-
-        TranslatedString = strdup(dgettext(domain, tmpStr));
-        if (tmpStr)
-        {
-            FREE(tmpStr);
-            tmpStr = NULL;
-        }
-
-        /* Add removed slashes */
-        if (revertStrsub)
-        {
-            char *tmpStr1 = NULL;
-            char *tmpStr2 = NULL;
-
-            tmpStr1 = strsub(TranslatedString, "\\", "\\\\"); /* backslash */
-
-            tmpStr2 = strsub(tmpStr1, "\f", "\\f"); /* form feed */
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-
-            tmpStr1 = strsub(tmpStr2, "\n", "\\n"); /* linefeed */
-            if (tmpStr2)
-            {
-                FREE(tmpStr2);
-                tmpStr2 = NULL;
-            }
-
-            tmpStr2 = strsub(tmpStr1, "\t", "\\t"); /* horizontal tab */
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-
-            tmpStr1 = strsub(tmpStr2, "\r", "\\r"); /* carriage return */
-            if (tmpStr2)
-            {
-                FREE(tmpStr2);
-                tmpStr2 = NULL;
-            }
-
-            tmpStr2 = strsub(tmpStr1, "\v", "\\v"); /* vertical tab */
-            if (tmpStr1)
-            {
-                FREE(tmpStr1);
-                tmpStr1 = NULL;
-            }
-
-            if (TranslatedString)
-            {
-                FREE(TranslatedString);
-                TranslatedString = NULL;
-            }
-
-            TranslatedString = strdup(tmpStr2);
-
-            if (tmpStr2)
-            {
-                FREE(tmpStr2);
-                tmpStr2 = NULL;
-            }
-        }
-        pStrConverted = TranslatedString;
-    }
-    return pStrConverted;
-}
-/*--------------------------------------------------------------------------*/
index 271a353..760091a 100644 (file)
@@ -2,6 +2,7 @@
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA - Sylvestre LEDRU
 * Copyright (C) 2009-2012 - DIGITEO - Allan CORNET
+* Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
 *
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 #include "strdup_windows.h"
 #endif
 #include "freeArrayOfString.h"
+
 /*--------------------------------------------------------------------------*/
-static char *convertString_gettext(const char *pStr);
+static char *convertString_dgettext(const char *domain, const char *pStr);
 /*--------------------------------------------------------------------------*/
 int sci_gettext(char *fname, unsigned long fname_len)
 {
     SciErr sciErr;
     int *piAddressVarOne = NULL;
+    char* pstDomain = NULL;
     char **TranslatedStrings = NULL;
     int m = 0;
     int n = 0;
+    char **StringsToTranslate = NULL;
+    int i = 0;
 
-    CheckRhs(1, 1);
-    CheckLhs(0, 1);
+    int iCurrentRhs = 1;
 
-    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
-    if (sciErr.iErr)
-    {
-        printError(&sciErr, 0);
-        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, 1);
-    }
+    int iRhs = nbInputArgument(pvApiCtx);
+    int iLhs = nbOutputArgument(pvApiCtx);
+
+    CheckInputArgument(pvApiCtx, 1, 2);
+    CheckOutputArgument(pvApiCtx, 0, 1);
 
-    if (isStringType(pvApiCtx, piAddressVarOne))
+    if (iRhs == 2)
     {
-        char **StringsToTranslate = NULL;
-        int i = 0;
-        if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarOne, &m, &n, &StringsToTranslate) != 0)
+        //get domain name
+        sciErr = getVarAddressFromPosition(pvApiCtx, iCurrentRhs, &piAddressVarOne);
+        if (sciErr.iErr)
         {
-            Scierror(999, _("%s: No more memory.\n"), fname);
-            return 0;
+            printError(&sciErr, 0);
+            Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iCurrentRhs);
         }
 
-        TranslatedStrings = (char **)MALLOC(sizeof(char*) * (m * n));
-        if (TranslatedStrings == NULL)
+        if (isStringType(pvApiCtx, piAddressVarOne) == 0 || isScalar(pvApiCtx, piAddressVarOne) == 0)
         {
-            freeAllocatedMatrixOfString(m, n, StringsToTranslate);
-            StringsToTranslate = NULL;
-            Scierror(999, _("%s: No more memory.\n"), fname);
+            Scierror(999, _("%s: Wrong size for input argument #%d: String expected.\n"), fname, iCurrentRhs);
             return 0;
         }
 
-        for (i = 0; i < m * n; i++)
+        if (getAllocatedSingleString(pvApiCtx, piAddressVarOne, &pstDomain))
         {
-            if (strcmp(StringsToTranslate[i], "") == 0)
-            {
-                TranslatedStrings[i] = strdup("");
-            }
-            else
-            {
-                TranslatedStrings[i] = convertString_gettext(StringsToTranslate[i]);
-            }
+            Scierror(999, _("%s: No more memory.\n"), fname);
+            return 0;
         }
 
+        iCurrentRhs++;
+    }
+
+    sciErr = getVarAddressFromPosition(pvApiCtx, iCurrentRhs, &piAddressVarOne);
+    if (sciErr.iErr)
+    {
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Can not read input argument #%d.\n"), fname, iCurrentRhs);
+    }
+
+    if (isStringType(pvApiCtx, piAddressVarOne) == 0)
+    {
+        Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
+        return 0;
+    }
+
+    if (getAllocatedMatrixOfString(pvApiCtx, piAddressVarOne, &m, &n, &StringsToTranslate) != 0)
+    {
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
+
+    TranslatedStrings = (char **)MALLOC(sizeof(char*) * (m * n));
+    if (TranslatedStrings == NULL)
+    {
         freeAllocatedMatrixOfString(m, n, StringsToTranslate);
         StringsToTranslate = NULL;
+        Scierror(999, _("%s: No more memory.\n"), fname);
+        return 0;
+    }
 
-        sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, m, n, TranslatedStrings);
-        freeArrayOfString(TranslatedStrings, m * n);
-        TranslatedStrings = NULL;
-
-        if (sciErr.iErr)
+    for (i = 0; i < m * n; i++)
+    {
+        if (strcmp(StringsToTranslate[i], "") == 0)
         {
-            printError(&sciErr, 0);
-            Scierror(999, _("%s: Memory allocation error.\n"), fname);
-            return 0;
+            TranslatedStrings[i] = strdup("");
+        }
+        else
+        {
+            //if pstDomain is NULL, default domain will be use
+            TranslatedStrings[i] = convertString_dgettext(pstDomain, StringsToTranslate[i]);
         }
-
-        LhsVar(1) = Rhs + 1;
-        PutLhsVar();
     }
-    else
+
+    freeAllocatedMatrixOfString(m, n, StringsToTranslate);
+    StringsToTranslate = NULL;
+
+    sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, m, n, TranslatedStrings);
+    freeArrayOfString(TranslatedStrings, m * n);
+    TranslatedStrings = NULL;
+
+    if (sciErr.iErr)
     {
-        Scierror(999, _("%s: Wrong type for input argument #%d: String expected.\n"), fname, 1);
+        printError(&sciErr, 0);
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
+        return 0;
     }
+
+    LhsVar(1) = Rhs + 1;
+    PutLhsVar();
     return 0;
 }
 /*--------------------------------------------------------------------------*/
-static char *convertString_gettext(const char *pStr)
+static char *convertString_dgettext(const char *domain, const char *pStr)
 {
     char *pStrConverted = NULL;
 
@@ -173,7 +206,7 @@ static char *convertString_gettext(const char *pStr)
             tmpStr = strdup(pStr);
         }
 
-        TranslatedString = strdup(gettext(tmpStr));
+        TranslatedString = strdup(dgettext(domain, tmpStr));
         if (tmpStr)
         {
             FREE(tmpStr);
index c5dd76b..51e9c00 100644 (file)
@@ -36,4 +36,5 @@
     <PRIMITIVE gatewayId="50" primitiveId="4" primitiveName="_" />
     <PRIMITIVE gatewayId="50" primitiveId="5" primitiveName="dgettext" />
     <PRIMITIVE gatewayId="50" primitiveId="6" primitiveName="setdefaultlanguage" />
+    <PRIMITIVE gatewayId="50" primitiveId="7" primitiveName="addlocalizationdomain" />
 </GATEWAY>
index 114dfa4..b26ea36 100644 (file)
@@ -246,6 +246,7 @@ lib /DEF:"$(ProjectDir)io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /O
     <None Include="..\Makefile.am" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\sci_gateway\c\sci_addlocalizationdomain.c" />
     <ClCompile Include="c\charEncoding.c" />
     <ClCompile Include="c\DllmainLocalization.c" />
     <ClCompile Include="c\getLcidString.c" />
@@ -257,7 +258,6 @@ lib /DEF:"$(ProjectDir)io_Import.def" /SUBSYSTEM:WINDOWS /MACHINE:$(Platform) /O
     <ClCompile Include="c\setdefaultlanguage.c" />
     <ClCompile Include="jni\LocaleToLCID_wrap.c" />
     <ClCompile Include="jni\Messages_wrap.c" />
-    <ClCompile Include="..\sci_gateway\c\sci_dgettext.c" />
     <ClCompile Include="..\sci_gateway\c\sci_getdefaultlanguage.c" />
     <ClCompile Include="..\sci_gateway\c\sci_getlanguage.c" />
     <ClCompile Include="..\sci_gateway\c\sci_gettext.c" />
index 057f964..a51f578 100644 (file)
     <ClCompile Include="jni\Messages_wrap.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\sci_gateway\c\sci_dgettext.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\sci_gateway\c\sci_getdefaultlanguage.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="jni\setdefaultlanguage_wrap.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\sci_gateway\c\sci_addlocalizationdomain.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="localization.rc">
diff --git a/scilab/modules/localization/tests/unit_tests/addlocalizationdomain.dia.ref b/scilab/modules/localization/tests/unit_tests/addlocalizationdomain.dia.ref
new file mode 100644 (file)
index 0000000..51d5691
--- /dev/null
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//===============================
+// unit tests addlocalizationdomain
+//===============================
+//error messages
+if execstr('addlocalizationdomain()','errcatch')==0 then bugmes();quit;end
+if execstr('addlocalizationdomain(""foo"")','errcatch')==0 then bugmes();quit;end
+addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale");
+setlanguage("fr_FR");
+assert_checkequal(gettext("%s: No more memory.\n"), "%s : Plus de mémoire disponible.\n");
+assert_checkequal(gettext("tbx", "%s: No more memory.\n"), "%s : Overwrite Scilab translation.\n");
+assert_checkequal(gettext("%s: something not in Scilab.\n"), "%s: something not in Scilab.\n");
+assert_checkequal(gettext("tbx", "%s: something not in Scilab.\n"), "%s : it is true, that is not in Scilab.\n");
diff --git a/scilab/modules/localization/tests/unit_tests/addlocalizationdomain.tst b/scilab/modules/localization/tests/unit_tests/addlocalizationdomain.tst
new file mode 100644 (file)
index 0000000..edab241
--- /dev/null
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+//===============================
+// unit tests addlocalizationdomain
+//===============================
+
+
+//error messages
+if execstr('addlocalizationdomain()','errcatch')==0 then pause,end
+if execstr('addlocalizationdomain(""foo"")','errcatch')==0 then pause,end
+
+addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale");
+setlanguage("fr_FR");
+assert_checkequal(gettext("%s: No more memory.\n"), "%s : Plus de mémoire disponible.\n");
+assert_checkequal(gettext("tbx", "%s: No more memory.\n"), "%s : Overwrite Scilab translation.\n");
+assert_checkequal(gettext("%s: something not in Scilab.\n"), "%s: something not in Scilab.\n");
+assert_checkequal(gettext("tbx", "%s: something not in Scilab.\n"), "%s : it is true, that is not in Scilab.\n");
index c13aef3..2308219 100644 (file)
@@ -1,12 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - INRIA - Sylvestre LEDRU <sylvestre.ledru@inria.fr>
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
 //===============================
 // unit tests gettext
-// INRIA 2008
-// @author Sylvestre LEDRU
 //===============================
 // Void call
 if execstr('gettext()','errcatch')==0 then bugmes();quit;end
-// two inputs arguments
-str1="plop"; str2="plip"; if execstr('gettext(str1, str2)','errcatch')==0 then bugmes();quit;end
+// three inputs arguments
+str1="plop"; str2="plip"; str3="plup"; if execstr('gettext(str1, str2, str3)','errcatch')==0 then bugmes();quit;end
 // Try to translate from en_US to en_US to a string which doesn't exist
 lang="en_US"; setlanguage(lang); msg="Localization does not exist"; if gettext(msg) <> msg then bugmes();quit;end
 // Try to translate from en_US to fr_FR to a string which doesn't exist
@@ -15,3 +19,9 @@ lang="fr_FR"; setlanguage(lang); msg="Startup execution:"; if gettext(msg) <> "I
 lang="fr"; setlanguage(lang); msg="Startup execution:"; if gettext(msg) <> "Initialisation :" then bugmes();quit;end
 lang="en"; setlanguage(lang); msg="Startup execution:"; if gettext(msg) <> msg then bugmes();quit;end
 lang="en_US"; setlanguage(lang); msg="Startup execution:"; if gettext(msg) <> msg then bugmes();quit;end
+addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale");
+setlanguage("fr_FR");
+assert_checkequal(gettext("%s: No more memory.\n"), "%s : Plus de mémoire disponible.\n");
+assert_checkequal(gettext("tbx", "%s: No more memory.\n"), "%s : Overwrite Scilab translation.\n");
+assert_checkequal(gettext("%s: something not in Scilab.\n"), "%s: something not in Scilab.\n");
+assert_checkequal(gettext("tbx", "%s: something not in Scilab.\n"), "%s : it is true, that is not in Scilab.\n");
index 3fbaa2a..387348f 100644 (file)
@@ -12,8 +12,8 @@
 // Void call
 if execstr('gettext()','errcatch')==0 then pause,end
 
-// two inputs arguments
-str1="plop"; str2="plip"; if execstr('gettext(str1, str2)','errcatch')==0 then pause,end
+// three inputs arguments
+str1="plop"; str2="plip"; str3="plup"; if execstr('gettext(str1, str2, str3)','errcatch')==0 then pause,end
 
 // Try to translate from en_US to en_US to a string which doesn't exist
 lang="en_US"; setlanguage(lang); msg="Localization does not exist"; if gettext(msg) <> msg then pause, end
@@ -29,3 +29,10 @@ lang="en"; setlanguage(lang); msg="Startup execution:"; if gettext(msg) <> msg t
 
 lang="en_US"; setlanguage(lang); msg="Startup execution:"; if gettext(msg) <> msg then pause, end
 
+addlocalizationdomain("tbx", "SCI/modules/localization/tests/unit_tests/locale");
+setlanguage("fr_FR");
+assert_checkequal(gettext("%s: No more memory.\n"), "%s : Plus de mémoire disponible.\n");
+assert_checkequal(gettext("tbx", "%s: No more memory.\n"), "%s : Overwrite Scilab translation.\n");
+assert_checkequal(gettext("%s: something not in Scilab.\n"), "%s: something not in Scilab.\n");
+assert_checkequal(gettext("tbx", "%s: something not in Scilab.\n"), "%s : it is true, that is not in Scilab.\n");
+
diff --git a/scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.mo b/scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.mo
new file mode 100644 (file)
index 0000000..0e866a7
Binary files /dev/null and b/scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.mo differ
diff --git a/scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.po b/scilab/modules/localization/tests/unit_tests/locale/en_US/LC_MESSAGES/tbx.po
new file mode 100644 (file)
index 0000000..fda2437
--- /dev/null
@@ -0,0 +1,27 @@
+# Localization of the module core
+# Please see in SCI/tools/localization for localization management
+# Copyright (C) 2007 - INRIA / Scilab
+# This file is distributed under the same license as the Scilab package.
+# Sylvestre Ledru <sylvestre.ledru@inria.fr>, 2007.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Scilab\n"
+"Report-Msgid-Bugs-To: <localization@lists.scilab.org>\n"
+"POT-Creation-Date: 2013-04-16 17:44+0100\n"
+"PO-Revision-Date: 2013-06-17 20:20+0000\n"
+"Last-Translator: jojolebestof <Unknown>\n"
+"Language-Team: Scilab Localization <localization@scilab.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Launchpad (build 16681)\n"
+"Language: \n"
+
+#, c-format
+msgid "%s: No more memory.\n"
+msgstr ""
+
+#, c-format
+msgid "%s: something not in Scilab.\n"
+msgstr ""
diff --git a/scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.mo b/scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.mo
new file mode 100644 (file)
index 0000000..55892f3
Binary files /dev/null and b/scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.mo differ
diff --git a/scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.po b/scilab/modules/localization/tests/unit_tests/locale/fr_FR/LC_MESSAGES/tbx.po
new file mode 100644 (file)
index 0000000..7dfc86c
--- /dev/null
@@ -0,0 +1,27 @@
+# Localization of the module core
+# Please see in SCI/tools/localization for localization management
+# Copyright (C) 2007 - INRIA / Scilab
+# This file is distributed under the same license as the Scilab package.
+# Sylvestre Ledru <sylvestre.ledru@inria.fr>, 2007.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Scilab\n"
+"Report-Msgid-Bugs-To: <localization@lists.scilab.org>\n"
+"POT-Creation-Date: 2013-04-16 17:44+0100\n"
+"PO-Revision-Date: 2013-06-17 20:20+0000\n"
+"Last-Translator: jojolebestof <Unknown>\n"
+"Language-Team: Scilab Localization <localization@scilab.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Launchpad (build 16681)\n"
+"Language: \n"
+
+#, c-format
+msgid "%s: No more memory.\n"
+msgstr "%s : Overwrite Scilab translation.\n"
+
+#, c-format
+msgid "%s: something not in Scilab.\n"
+msgstr "%s : it is true, that is not in Scilab.\n"