add convert locale name to LCID (used for chm build) on Windows 92/2392/4
Allan CORNET [Mon, 1 Nov 2010 17:05:34 +0000 (18:05 +0100)]
Change-Id: Ia2bf4ff39b72d98c960722cb23f065e6ea61ba69

12 files changed:
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/CHMDocbookTagConverter.java
scilab/modules/helptools/src/java/org/scilab/forge/scidoc/SciDocMain.java
scilab/modules/localization/Makefile.am
scilab/modules/localization/Makefile.in
scilab/modules/localization/src/c/getLcidString.c [new file with mode: 0644]
scilab/modules/localization/src/c/getLcidString.h [new file with mode: 0644]
scilab/modules/localization/src/java/org/scilab/modules/localization/LocaleToLCID.java [new file with mode: 0644]
scilab/modules/localization/src/java/org/scilab/modules/localization/LocaleToLCIDJNI.java [new file with mode: 0644]
scilab/modules/localization/src/jni/LocaleToLCID.i [new file with mode: 0644]
scilab/modules/localization/src/jni/LocaleToLCID_wrap.c [new file with mode: 0644]
scilab/modules/localization/src/localization.vcproj
scilab/modules/localization/src/localization_export.def

index 3c1c4f1..13bd892 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*9
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2010 - Calixte DENIZET
  *
@@ -29,6 +29,8 @@ import java.util.Stack;
 
 import org.xml.sax.SAXException;
 
+import org.scilab.modules.localization.LocaleToLCID;
+
 /**
  * Class to convert DocBook to CHM
  * @author Calixte DENIZET
@@ -38,6 +40,7 @@ public class CHMDocbookTagConverter extends HTMLDocbookTagConverter {
     private StringBuilder buffer = new StringBuilder(8192);
     private String outName;
     private List<String> filesList = new ArrayList();
+    private String language;
 
     /**
      * Constructor
@@ -46,9 +49,10 @@ public class CHMDocbookTagConverter extends HTMLDocbookTagConverter {
      * @param macroConf the file containing the macros of Scilab
      * @param out the output stream
      */
-    public CHMDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir, boolean checkLast) throws IOException, SAXException {
+    public CHMDocbookTagConverter(String inName, String outName, String primConf, String macroConf, String template, String version, String imageDir, boolean checkLast, String language) throws IOException, SAXException {
         super(inName, outName, primConf, macroConf, template, version, imageDir, checkLast);
         this.outName = new File(outName).getCanonicalPath() + File.separator;
+        this.language = language;
     }
 
     /**
@@ -190,7 +194,7 @@ public class CHMDocbookTagConverter extends HTMLDocbookTagConverter {
         buffer.append("Display compile progress=Yes\n");
         buffer.append("Full-text search=Yes\n");
         buffer.append("Language=");
-        buffer.append("0x0409");// Allan : code pr la langue
+        buffer.append(LocaleToLCID.convert(language));
         buffer.append("\nTitle=");
         buffer.append(bookTitle);
         buffer.append("\nEnhanced decompilation=No\n\n");
index e7ec0ff..7c06c0f 100644 (file)
@@ -168,7 +168,7 @@ public final class SciDocMain {
             } else if (format.equalsIgnoreCase("html")) {
                 converter = new HTMLDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, checkLast);
             } else if (format.equalsIgnoreCase("chm")) {
-                converter = new CHMDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, checkLast);
+                converter = new CHMDocbookTagConverter(sourceDoc, outputDirectory, sciprim, scimacro, template, version, imagedir, checkLast, language);
             }
 
             converter.registerExternalXMLHandler(new HTMLMathMLHandler(outputDirectory, imagedir));
index b742415..4fc6836 100644 (file)
 LOCALIZATION_C_SOURCES = \
 src/c/InitializeLocalization.c \
 src/c/setgetlanguage.c \
+src/c/getLcidString.c \
 src/c/charEncoding.c
 
 if NEED_JAVA
-LOCALIZATION_C_SOURCES+=src/jni/Messages_wrap.c
+LOCALIZATION_C_SOURCES+=src/jni/Messages_wrap.c \
+src/jni/LocaleToLCID_wrap.c
 endif
 
 if IS_MACOSX
@@ -84,7 +86,8 @@ USEANT=1
 endif
 
 #### SWIG Declaration ####
-SWIG_WRAPPERS = src/jni/Messages.i 
+SWIG_WRAPPERS = src/jni/Messages.i \
+src/jni/LocaleToLCID.i
 
 if SWIG
 BUILT_SOURCES=swig
index 4c7fb4d..7f4a197 100644 (file)
@@ -61,7 +61,9 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-@NEED_JAVA_TRUE@am__append_1 = src/jni/Messages_wrap.c
+@NEED_JAVA_TRUE@am__append_1 = src/jni/Messages_wrap.c \
+@NEED_JAVA_TRUE@src/jni/LocaleToLCID_wrap.c
+
 @IS_MACOSX_TRUE@am__append_2 = src/c/getLocaleInfo_Apple.c
 @IS_MACOSX_TRUE@am__append_3 = -lintl -framework Cocoa
 @IS_MACOSX_TRUE@am__append_4 = -lintl -framework Cocoa
@@ -127,7 +129,8 @@ libscilocalization_la_DEPENDENCIES =  \
        $(top_builddir)/modules/output_stream/libscioutput_stream.la
 am__libscilocalization_la_SOURCES_DIST =  \
        src/c/InitializeLocalization.c src/c/setgetlanguage.c \
-       src/c/charEncoding.c src/jni/Messages_wrap.c \
+       src/c/getLcidString.c src/c/charEncoding.c \
+       src/jni/Messages_wrap.c src/jni/LocaleToLCID_wrap.c \
        src/c/getLocaleInfo_Apple.c sci_gateway/c/gw_localization.c \
        sci_gateway/c/sci_gettext.c sci_gateway/c/sci_dgettext.c \
        sci_gateway/c/sci_setlanguage.c \
@@ -135,11 +138,13 @@ am__libscilocalization_la_SOURCES_DIST =  \
        sci_gateway/c/sci_getlanguage.c \
        sci_gateway/c/sci_setdefaultlanguage.c
 @NEED_JAVA_TRUE@am__objects_1 =  \
-@NEED_JAVA_TRUE@       libscilocalization_la-Messages_wrap.lo
+@NEED_JAVA_TRUE@       libscilocalization_la-Messages_wrap.lo \
+@NEED_JAVA_TRUE@       libscilocalization_la-LocaleToLCID_wrap.lo
 @IS_MACOSX_TRUE@am__objects_2 =  \
 @IS_MACOSX_TRUE@       libscilocalization_la-getLocaleInfo_Apple.lo
 am__objects_3 = libscilocalization_la-InitializeLocalization.lo \
        libscilocalization_la-setgetlanguage.lo \
+       libscilocalization_la-getLcidString.lo \
        libscilocalization_la-charEncoding.lo $(am__objects_1) \
        $(am__objects_2)
 am__objects_4 = libscilocalization_la-gw_localization.lo \
@@ -423,8 +428,8 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 LOCALIZATION_C_SOURCES = src/c/InitializeLocalization.c \
-       src/c/setgetlanguage.c src/c/charEncoding.c $(am__append_1) \
-       $(am__append_2)
+       src/c/setgetlanguage.c src/c/getLcidString.c \
+       src/c/charEncoding.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 \
@@ -474,7 +479,9 @@ includes/charEncoding.h
 @GUI_TRUE@USEANT = 1
 
 #### SWIG Declaration ####
-SWIG_WRAPPERS = src/jni/Messages.i 
+SWIG_WRAPPERS = src/jni/Messages.i \
+src/jni/LocaleToLCID.i
+
 @SWIG_TRUE@BUILT_SOURCES = swig
 
 # Where all the Scilab stuff is installed (macros, help, ...)
@@ -615,8 +622,10 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-InitializeLocalization.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-LocaleToLCID_wrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-Messages_wrap.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-charEncoding.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-getLcidString.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscilocalization_la-getLocaleInfo_Apple.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@
@@ -662,6 +671,13 @@ libscilocalization_la-setgetlanguage.lo: src/c/setgetlanguage.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-setgetlanguage.lo `test -f 'src/c/setgetlanguage.c' || echo '$(srcdir)/'`src/c/setgetlanguage.c
 
+libscilocalization_la-getLcidString.lo: src/c/getLcidString.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-getLcidString.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-getLcidString.Tpo -c -o libscilocalization_la-getLcidString.lo `test -f 'src/c/getLcidString.c' || echo '$(srcdir)/'`src/c/getLcidString.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscilocalization_la-getLcidString.Tpo $(DEPDIR)/libscilocalization_la-getLcidString.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='src/c/getLcidString.c' object='libscilocalization_la-getLcidString.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-getLcidString.lo `test -f 'src/c/getLcidString.c' || echo '$(srcdir)/'`src/c/getLcidString.c
+
 libscilocalization_la-charEncoding.lo: src/c/charEncoding.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-charEncoding.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-charEncoding.Tpo -c -o libscilocalization_la-charEncoding.lo `test -f 'src/c/charEncoding.c' || echo '$(srcdir)/'`src/c/charEncoding.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscilocalization_la-charEncoding.Tpo $(DEPDIR)/libscilocalization_la-charEncoding.Plo
@@ -676,6 +692,13 @@ libscilocalization_la-Messages_wrap.lo: src/jni/Messages_wrap.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-Messages_wrap.lo `test -f 'src/jni/Messages_wrap.c' || echo '$(srcdir)/'`src/jni/Messages_wrap.c
 
+libscilocalization_la-LocaleToLCID_wrap.lo: src/jni/LocaleToLCID_wrap.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-LocaleToLCID_wrap.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-LocaleToLCID_wrap.Tpo -c -o libscilocalization_la-LocaleToLCID_wrap.lo `test -f 'src/jni/LocaleToLCID_wrap.c' || echo '$(srcdir)/'`src/jni/LocaleToLCID_wrap.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscilocalization_la-LocaleToLCID_wrap.Tpo $(DEPDIR)/libscilocalization_la-LocaleToLCID_wrap.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='src/jni/LocaleToLCID_wrap.c' object='libscilocalization_la-LocaleToLCID_wrap.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-LocaleToLCID_wrap.lo `test -f 'src/jni/LocaleToLCID_wrap.c' || echo '$(srcdir)/'`src/jni/LocaleToLCID_wrap.c
+
 libscilocalization_la-getLocaleInfo_Apple.lo: src/c/getLocaleInfo_Apple.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-getLocaleInfo_Apple.lo -MD -MP -MF $(DEPDIR)/libscilocalization_la-getLocaleInfo_Apple.Tpo -c -o libscilocalization_la-getLocaleInfo_Apple.lo `test -f 'src/c/getLocaleInfo_Apple.c' || echo '$(srcdir)/'`src/c/getLocaleInfo_Apple.c
 @am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libscilocalization_la-getLocaleInfo_Apple.Tpo $(DEPDIR)/libscilocalization_la-getLocaleInfo_Apple.Plo
diff --git a/scilab/modules/localization/src/c/getLcidString.c b/scilab/modules/localization/src/c/getLcidString.c
new file mode 100644 (file)
index 0000000..e020190
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - 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-en.txt
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#include <string.h>
+#include <stdio.h>
+#ifdef _MSC_VER
+#include <Windows.h>
+#endif
+#include "getLcidString.h"
+#include "MALLOC.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+#include "charEncoding.h"
+#include "stack-def.h"
+/*--------------------------------------------------------------------------*/
+#define DEFAULT_EN_LCID "0x0409"
+/*--------------------------------------------------------------------------*/
+#ifdef _MSC_VER
+/* replaces '_' by '-' windows local format and convert to wide string */
+static wchar_t *getWindowsLocaleFormat(const char *pStrLocale);
+#endif
+/*--------------------------------------------------------------------------*/
+char *getLcidString(const char *pStrLocale)
+{
+    char *pStrLCID = NULL;
+
+    if (pStrLocale == NULL) 
+    {
+        return strdup(DEFAULT_EN_LCID);
+    }
+#ifdef _MSC_VER
+    if ((strcmp(pStrLocale, "") == 0) || (strcmp(pStrLocale, "C") == 0))
+    {
+        return strdup(DEFAULT_EN_LCID);
+    }
+    else
+    {
+        wchar_t *wLocale = getWindowsLocaleFormat(pStrLocale);
+        LCID lcid = LocaleNameToLCID(wLocale, 0);
+
+        if (lcid == 0)
+        {
+            pStrLCID = strdup(DEFAULT_EN_LCID);
+        }
+        else
+        {
+            pStrLCID = (char *)MALLOC(sizeof(char)*bsiz);
+            if (pStrLCID)
+            {
+                /*
+                DWORD LangID = LANGIDFROMLCID(lcid);
+                WORD PrimaryLangID = PRIMARYLANGID(LangID);
+                WORD SubLangID = SUBLANGID(LangID);
+                */
+
+                sprintf(pStrLCID, "0x0%x", lcid);
+            }
+        }
+    }
+#else
+    /* this routines not used on others platforms */
+    pStrLCID = strdup(DEFAULT_EN_LCID);
+#endif
+    return pStrLCID;
+}
+/*--------------------------------------------------------------------------*/
+#ifdef _MSC_VER
+static wchar_t *getWindowsLocaleFormat(const char *pStrLocale)
+{
+    wchar_t *Locale = NULL;
+    if (pStrLocale)
+    {
+        wchar_t *pwStrLocale = to_wide_string(pStrLocale);
+        if (pwStrLocale)
+        {
+            wchar_t *pos = wcschr(pwStrLocale, L'_');
+            if (pos)
+            {
+                int len = (int)wcslen(pos);
+                pwStrLocale[len] = L'-';
+            }
+            Locale = pwStrLocale;
+        }
+    }
+    return Locale;
+}
+#endif
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/localization/src/c/getLcidString.h b/scilab/modules/localization/src/c/getLcidString.h
new file mode 100644 (file)
index 0000000..88469ca
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - 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-en.txt
+ *
+ */
+/*--------------------------------------------------------------------------*/
+#ifndef __GETLCIDSTRING_H__
+#define __GETLCIDSTRING_H__
+
+/**
+* convert Locale name to LCID string
+* used by CHM
+* http://msdn.microsoft.com/en-us/library/0h88fahh(VS.85).aspx
+* @param[in] locale name ex: en_US
+* @return LCID string ex: 0x0409
+*/
+char *getLcidString(const char *pStrLocale);
+
+#endif /* __GETLCIDSTRING_H__ */
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/localization/src/java/org/scilab/modules/localization/LocaleToLCID.java b/scilab/modules/localization/src/java/org/scilab/modules/localization/LocaleToLCID.java
new file mode 100644 (file)
index 0000000..4d20c38
--- /dev/null
@@ -0,0 +1,28 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.scilab.modules.localization;
+
+
+ /** 
+   * @author Allan CORNET
+   * @copyright DIGITEO 2010
+   */
+public class LocaleToLCID {
+
+ /**
+   * Constructor
+   */
+ protected LocaleToLCID() {
+    throw new UnsupportedOperationException();
+ }
+  public static String convert(String pStrLocale) {
+    return LocaleToLCIDJNI.convert(pStrLocale);
+  }
+
+}
diff --git a/scilab/modules/localization/src/java/org/scilab/modules/localization/LocaleToLCIDJNI.java b/scilab/modules/localization/src/java/org/scilab/modules/localization/LocaleToLCIDJNI.java
new file mode 100644 (file)
index 0000000..57e1351
--- /dev/null
@@ -0,0 +1,42 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.scilab.modules.localization;
+
+
+/* It is generated code. Disable checkstyle */
+//CHECKSTYLE:OFF
+ /** 
+   * @author Allan CORNET
+   * @copyright DIGITEO 2010
+   */
+public class LocaleToLCIDJNI {
+
+  /**
+    * Constructor
+    */
+  protected LocaleToLCIDJNI() {
+    throw new UnsupportedOperationException();
+  }
+
+  static {
+    try {
+        System.loadLibrary("scilocalization");
+    } catch (SecurityException e) {
+        System.err.println("A security manager exists and does not allow the loading of the specified dynamic library.");
+        System.err.println(e.getLocalizedMessage());
+        e.printStackTrace(System.err);
+    } catch (UnsatisfiedLinkError e)    {
+        System.err.println("The native library scilocalization does not exist or cannot be found.");
+        System.err.println(e.getLocalizedMessage());
+        e.printStackTrace(System.err);
+    }
+  }
+
+  public final static native String convert(String jarg1);
+}
diff --git a/scilab/modules/localization/src/jni/LocaleToLCID.i b/scilab/modules/localization/src/jni/LocaleToLCID.i
new file mode 100644 (file)
index 0000000..4a55e2a
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - 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-en.txt
+ *
+ */
+/* Messages.i */
+/**
+ * Windows: swig -java -package org.scilab.modules.localization -outdir ../java/org/scilab/modules/localization/ LocaleToLCID.i 
+ * Others: Use the option --enable-build-swig to the configure
+*/
+%module LocaleToLCID
+
+%{
+#include "getLcidString.h"
+%}
+
+/* JavaDoc for LocaleToLCIDJNI class */
+%pragma(java) jniclassclassmodifiers=%{
+/* It is generated code. Disable checkstyle */
+//CHECKSTYLE:OFF
+ /** 
+   * @author Allan CORNET
+   * @copyright DIGITEO 2010
+   */
+public class%}
+
+/* Constructor for LocaleToLCIDJNI class */
+%pragma(java) jniclasscode="
+  /**
+    * Constructor
+    */
+  protected LocaleToLCIDJNI() {
+    throw new UnsupportedOperationException();
+  }";
+
+/* static load of library */
+%pragma(java) jniclasscode=%{
+  static {
+    try {
+        System.loadLibrary("scilocalization");
+    } catch (SecurityException e) {
+        System.err.println("A security manager exists and does not allow the loading of the specified dynamic library.");
+        System.err.println(e.getLocalizedMessage());
+        e.printStackTrace(System.err);
+    } catch (UnsatisfiedLinkError e)    {
+        System.err.println("The native library scilocalization does not exist or cannot be found.");
+        System.err.println(e.getLocalizedMessage());
+        e.printStackTrace(System.err);
+    }
+  }
+%}
+
+/* JavaDoc for LocaleToLCID class */
+%pragma(java) moduleclassmodifiers="
+ /** 
+   * @author Allan CORNET
+   * @copyright DIGITEO 2010
+   */
+public class";
+
+/* Constructor for LocaleToLCID class */
+%pragma(java) modulecode="
+ /**
+   * Constructor
+   */
+ protected LocaleToLCID() {
+    throw new UnsupportedOperationException();
+ }";
+
+/* JavaDoc */
+%javamethodmodifiers convert(const char *locale) "
+/**
+* convert a locale string to LCID string used by CHM builder
+* @param[in] string the key of the message (usually the english msg)
+* @return LCID string
+*/
+public";
+
+
+%rename(convert) getLcidString;
+char *getLcidString(const char *pStrLocale);
diff --git a/scilab/modules/localization/src/jni/LocaleToLCID_wrap.c b/scilab/modules/localization/src/jni/LocaleToLCID_wrap.c
new file mode 100644 (file)
index 0000000..6f04f7b
--- /dev/null
@@ -0,0 +1,219 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.40
+ * 
+ * This file is not intended to be easily readable and contains a number of 
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG 
+ * interface file instead. 
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGJAVA
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__)) 
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__)) 
+# else
+#   define SWIGUNUSED 
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif 
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif 
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Fix for jlong on some versions of gcc on Windows */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+  typedef long long __int64;
+#endif
+
+/* Fix for jlong on 64-bit x86 Solaris */
+#if defined(__x86_64)
+# ifdef _LP64
+#   undef _LP64
+# endif
+#endif
+
+#include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Support for throwing Java exceptions */
+typedef enum {
+  SWIG_JavaOutOfMemoryError = 1, 
+  SWIG_JavaIOException, 
+  SWIG_JavaRuntimeException, 
+  SWIG_JavaIndexOutOfBoundsException,
+  SWIG_JavaArithmeticException,
+  SWIG_JavaIllegalArgumentException,
+  SWIG_JavaNullPointerException,
+  SWIG_JavaDirectorPureVirtual,
+  SWIG_JavaUnknownError
+} SWIG_JavaExceptionCodes;
+
+typedef struct {
+  SWIG_JavaExceptionCodes code;
+  const char *java_exception;
+} SWIG_JavaExceptions_t;
+
+
+static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
+  jclass excep;
+  static const SWIG_JavaExceptions_t java_exceptions[] = {
+    { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
+    { SWIG_JavaIOException, "java/io/IOException" },
+    { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
+    { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
+    { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
+    { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
+    { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
+    { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
+    { SWIG_JavaUnknownError,  "java/lang/UnknownError" },
+    { (SWIG_JavaExceptionCodes)0,  "java/lang/UnknownError" }
+  };
+  const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
+
+  while (except_ptr->code != code && except_ptr->code)
+    except_ptr++;
+
+  (*jenv)->ExceptionClear(jenv);
+  excep = (*jenv)->FindClass(jenv, except_ptr->java_exception);
+  if (excep)
+    (*jenv)->ThrowNew(jenv, excep, msg);
+}
+
+
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else
+
+
+#include "getLcidString.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGEXPORT jstring JNICALL Java_org_scilab_modules_localization_LocaleToLCIDJNI_convert(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+  jstring jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+    if (!arg1) return 0;
+  }
+  result = (char *)getLcidString((char const *)arg1);
+  if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
+  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+  return jresult;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
index be9a64f..22540b1 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <VisualStudioProject
        ProjectType="Visual C++"
        Version="9,00"
@@ -38,6 +38,9 @@
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                        />
                        <Tool
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                                TargetEnvironment="3"
                        />
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                        />
                        <Tool
                                OutputFile="$(SolutionDir)bin\sci$(ProjectName).dll"
                                IgnoreDefaultLibraryNames=""
                                ModuleDefinitionFile="localization_export.def"
-
                                RandomizedBaseAddress="1"
                                DataExecutionPrevention="0"
                                SupportUnloadOfDelayLoadedDLL="true"
                                Name="VCXMLDataGeneratorTool"
                        />
                        <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
                                Name="VCMIDLTool"
                                TargetEnvironment="3"
                        />
                                OutputFile="$(SolutionDir)bin\sci$(ProjectName).dll"
                                IgnoreDefaultLibraryNames=""
                                ModuleDefinitionFile="localization_export.def"
-
                                RandomizedBaseAddress="1"
                                DataExecutionPrevention="0"
                                SupportUnloadOfDelayLoadedDLL="true"
                                >
                        </File>
                        <File
+                               RelativePath=".\c\getLcidString.h"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\c\getLocaleInfo_Windows.h"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath=".\c\getLcidString.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\c\getLocaleInfo_Windows.c"
                                >
                        </File>
                                >
                        </File>
                        <File
+                               RelativePath=".\jni\LocaleToLCID_wrap.c"
+                               >
+                       </File>
+                       <File
                                RelativePath=".\jni\Messages_wrap.c"
                                >
                        </File>