setgetlanguage.h File Reference

#include "machine.h"

Include dependency graph for setgetlanguage.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL setlanguage (char *lang, BOOL updateHelpIndex, BOOL updateMenus)
char * getlanguage (void)
char * getlanguagealias (void)
int getcurrentlanguagecode (void)
char * getlanguagefromcode (int code)
int getcodefromlanguage (char *language)
int comparelanguages (char *language1, char *language2)
BOOL needtochangelanguage (char *language)
char * convertlanguagealias (char *strlanguage)


Function Documentation

int comparelanguages ( char *  language1,
char *  language2 
)

TODO compare 2 languages same or not ?

Parameters:
language 
Returns:

Definition at line 185 of file setgetlanguage.c.

Referenced by needtochangelanguage().

00186 {
00187         return strcmp(language1,language2);
00188 }

Here is the caller graph for this function:

char* convertlanguagealias ( char *  strlanguage  ) 

TODO try to convert strlanguage (alias) to a good language string

Parameters:
language 
Returns:

Definition at line 204 of file setgetlanguage.c.

References GetLanguageFromAlias(), and NULL.

Referenced by C2F().

00205 {
00206         char *correctlanguage=NULL;
00207 
00208         if (strlen(strlanguage)==2)
00209         {
00210                 correctlanguage=GetLanguageFromAlias(strlanguage);
00211         }
00212         else if (strcmp(strlanguage,"eng")==0) /* compatibility previous scilab */
00213         {
00214                 correctlanguage=GetLanguageFromAlias("en");
00215         }
00216         return correctlanguage;
00217 }

Here is the call graph for this function:

Here is the caller graph for this function:

int getcodefromlanguage ( char *  language  ) 

TODO get code of a language

Parameters:
language 
Returns:

Definition at line 98 of file setgetlanguage.c.

References FindLanguageCode().

00099 {
00100         return FindLanguageCode(language);
00101 }

Here is the call graph for this function:

int getcurrentlanguagecode ( void   ) 

TODO return internal code associated with a language

Returns:

Definition at line 76 of file setgetlanguage.c.

References CURRENTLANGUAGECODE.

00077 {
00078         return CURRENTLANGUAGECODE;
00079 }

char* getlanguage ( void   ) 

TODO returns current language

Returns:

Definition at line 66 of file setgetlanguage.c.

References CURRENTLANGUAGESTRING, MALLOC, and NULL.

Referenced by C2F(), needtochangelanguage(), and savelanguagepref_linux().

00067 {
00068         char *RetLanguage=NULL;
00069 
00070         RetLanguage=(char*)MALLOC(sizeof(char)*(strlen(CURRENTLANGUAGESTRING)+1));
00071         strcpy(RetLanguage,CURRENTLANGUAGESTRING);
00072 
00073         return RetLanguage;
00074 }

Here is the caller graph for this function:

char* getlanguagealias ( void   ) 

TODO returns current alias example : en_US --> en

Returns:

Definition at line 180 of file setgetlanguage.c.

References CURRENTLANGUAGESTRING, and FindAlias().

Referenced by C2F().

00181 {
00182         return FindAlias(CURRENTLANGUAGESTRING);
00183 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* getlanguagefromcode ( int  code  ) 

TODO returns language of code

Parameters:
code 
Returns:

Definition at line 81 of file setgetlanguage.c.

References i, LANGUAGE_COUNTRY_TAB, MALLOC, NULL, and NumberLanguages.

00082 {
00083         char *RetLanguage=NULL;
00084         int i=0;
00085 
00086         for (i=0;i<NumberLanguages;i++)
00087         {
00088                 if (LANGUAGE_COUNTRY_TAB[i].code == code)
00089                 {
00090                         RetLanguage=(char*)MALLOC(sizeof(char)*(strlen(LANGUAGE_COUNTRY_TAB[i].alphacode)+1));
00091                         strcpy(RetLanguage,LANGUAGE_COUNTRY_TAB[i].alphacode);
00092                         return RetLanguage;
00093                 }
00094         }
00095         return RetLanguage;
00096 }

BOOL needtochangelanguage ( char *  language  ) 

TODO test if we need to change language

Parameters:
language 
Returns:

Definition at line 190 of file setgetlanguage.c.

References comparelanguages(), FALSE, FREE, getlanguage(), NULL, and TRUE.

Referenced by C2F(), and setlanguage().

00191 {
00192         BOOL bOK=FALSE;
00193         char *currentlanguage=NULL;
00194 
00195         currentlanguage=getlanguage();
00196 
00197         if (comparelanguages(language,currentlanguage)) bOK=TRUE;
00198 
00199         if (currentlanguage) {FREE(currentlanguage);currentlanguage=NULL;}
00200 
00201         return bOK;
00202 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL setlanguage ( char *  lang,
BOOL  updateHelpIndex,
BOOL  updateMenus 
)

TODO change language

Parameters:
lang 

Definition at line 24 of file setgetlanguage.c.

References C2F, CURRENTLANGUAGESTRING, FALSE, ierr, int, LanguageIsOK(), LoadHashTablesLocalization(), needtochangelanguage(), savelanguagepref(), setlanguagecode(), syncexec(), TRUE, and UPDATESCILABHELPMACRO.

Referenced by C2F(), and loadlanguagepref_linux().

00025 {
00026         BOOL bOK=FALSE;
00027         if (lang)
00028         {
00029                 if ( LanguageIsOK(lang) )
00030                 {
00031                         if (needtochangelanguage(lang))
00032                         {
00033                                 /* change language */
00034                                 strcpy(CURRENTLANGUAGESTRING,lang);
00035                                 setlanguagecode(lang);
00036 
00037                                 if (updateHelpIndex)
00038                                 {
00039                                         #define UPDATESCILABHELPMACRO "try update_scilab_help();catch end;" 
00040                                         integer ierr ;
00041                                         integer seq = 1 ;
00042                                         int macroCallLength=0;
00043 
00044                                         /* update help index */
00045                                         macroCallLength = (int)strlen(UPDATESCILABHELPMACRO);
00046                                         C2F(syncexec)(UPDATESCILABHELPMACRO,&macroCallLength,&ierr,&seq, macroCallLength);
00047                                 }
00048 
00049                                 /* save language pref. */
00050                                 savelanguagepref();
00051 
00052                                 /* update hash tables messages , errors , menus */
00053                                 LoadHashTablesLocalization(lang);
00054 
00055                                 if (updateMenus)
00056                                 {
00057                                         /* changes menus : to do after */
00058                                 }
00059                                 bOK=TRUE;
00060                         }
00061                 }
00062         }
00063         return bOK;
00064 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Sun Mar 4 16:09:59 2007 for Scilab [trunk] by  doxygen 1.5.1