2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2008 - INRIA - Sylvestre LEDRU
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
16 #include "localization.h"
17 #include "gw_localization.h"
20 /*--------------------------------------------------------------------------*/
21 int C2F(sci_gettext)(char *fname,unsigned long fname_len)
26 if ( (GetType(1) == sci_strings) )
31 char *TranslatedString = NULL;
33 int revertStrsub = FALSE;
35 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
38 /* This stupid stuff is necessary because scilab is add slashes
39 * and we need to remove them
40 * An other solution might be to replace the string "\x" by it
43 if (strchr(msgid, '\\')!=NULL)
45 /* There is an \ in the string process to replace */
47 /* We always have something from this functions because gettext
48 * is returning the same string if it cannot find it */
50 msgid = strsub(msgid, "\\n", "\n"); /* linefeed */
51 msgid = strsub(msgid, "\\t", "\t"); /* horizontal tab */
52 msgid = strsub(msgid, "\\r", "\r"); /* carriage return */
53 msgid = strsub(msgid, "\\v", "\v"); /* vertical tab */
54 msgid = strsub(msgid, "\\f", "\f"); /* form feed */
55 msgid = strsub(msgid, "\\\\", "\\"); /* backslash */
56 msgid = strsub(msgid, "\\\"", "\""); /* double quote */
60 TranslatedString = gettext(msgid);
62 /* Add removed slashes */
65 TranslatedString = strsub(TranslatedString, "\\", "\\\\"); /* backslash */
66 TranslatedString = strsub(TranslatedString, "\"", "\\\""); /* double quote */
67 TranslatedString = strsub(TranslatedString, "\n", "\\n"); /* linefeed */
68 TranslatedString = strsub(TranslatedString, "\t", "\\t"); /* horizontal tab */
69 TranslatedString = strsub(TranslatedString, "\r", "\\r"); /* carriage return */
70 TranslatedString = strsub(TranslatedString, "\v", "\\v"); /* vertical tab */
71 TranslatedString = strsub(TranslatedString, "\f", "\\f"); /* form feed */
75 CreateVarFromPtr(Rhs+1,STRING_DATATYPE,(m1=(int)strlen(TranslatedString), &m1),&n1,&TranslatedString);
81 Scierror(999,_("%s: Wrong type for first input argument: String expected.\n"),fname);
85 /*--------------------------------------------------------------------------*/