#include "config.h"
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <libergtk/ergtk.h>
#include "setupLog.h"
#include "gettext.h"
#include "languages.h"
#include "iLiadConfigData.h"
Go to the source code of this file.
| Functions | |
| static int | locale_cmp (const void *left, const void *right) | 
| guint | find_installed_locales (iLiad_locale_t **locale_installed_tbl) | 
| void | free_installed_locales (iLiad_locale_t **locale_installed_tbl, gint locale_installed_num) | 
| void | languagesInit () | 
| Variables | |
| static const iLiad_locale_t | g_locale_known_tbl [] | 
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.
<File description>="">
Definition in file languages.c.
| guint find_installed_locales | ( | iLiad_locale_t ** | locale_installed_tbl | ) | 
Definition at line 96 of file languages.c.
00097 { 00098 ST_LOGPRINTF("entry"); 00099 00100 int num; 00101 DIR *dirp; 00102 struct dirent *direntp; 00103 struct stat statbuf; 00104 char *cp; 00105 int i; 00106 00107 const iLiad_locale_t *locp; 00108 00109 int locale_installed_num = 0; 00110 iLiad_locale_t* loc_locale_installed_tbl= NULL; 00111 00112 // get locales currently installed 00113 dirp = opendir(LOCALE_LIB_DIR); 00114 if (dirp) 00115 { 00116 // count number of directory entries 00117 num = 0; 00118 while ((direntp = readdir(dirp)) != NULL) 00119 { 00120 num++; 00121 } 00122 00123 // allocate table for installed locales 00124 loc_locale_installed_tbl = g_new0(iLiad_locale_t, num); 00125 locale_installed_num = 0; 00126 00127 // get currently installed locales 00128 rewinddir(dirp); 00129 while ((direntp = readdir(dirp)) != NULL) 00130 { 00131 cp = g_strdup_printf(LOCALE_LIB_DIR "/%s", direntp->d_name); 00132 i = stat(cp, &statbuf); 00133 g_free(cp); 00134 if ( i == 0 00135 && S_ISDIR(statbuf.st_mode) 00136 && direntp->d_name[0] != '.' ) 00137 { 00138 // strip extension, if any 00139 cp = strchr(direntp->d_name, '.'); 00140 if (cp) 00141 { 00142 *cp = '\0'; 00143 } 00144 00145 // find locale in known locales 00146 for (locp = g_locale_known_tbl ; locp->code ; locp++) 00147 { 00148 if (strcmp(direntp->d_name, locp->code) == 0) 00149 { 00150 // found 00151 break; // exit for 00152 } 00153 } 00154 00155 // add this locale to installed locales 00156 if (locp->code) 00157 { 00158 loc_locale_installed_tbl[locale_installed_num].code = g_strdup(locp->code ); 00159 loc_locale_installed_tbl[locale_installed_num].name = g_strdup(locp->name ); 00160 loc_locale_installed_tbl[locale_installed_num].long_name = g_strdup(locp->long_name); 00161 locale_installed_num++; 00162 } 00163 else 00164 { 00165 loc_locale_installed_tbl[locale_installed_num].code = g_strdup(direntp->d_name); 00166 loc_locale_installed_tbl[locale_installed_num].name = g_strdup(direntp->d_name); 00167 loc_locale_installed_tbl[locale_installed_num].long_name = g_strdup(direntp->d_name); 00168 locale_installed_num++; 00169 } 00170 } 00171 } 00172 00173 // sort installed locales on name 00174 qsort( loc_locale_installed_tbl, 00175 locale_installed_num, 00176 sizeof(loc_locale_installed_tbl[0]), 00177 locale_cmp ); 00178 00179 closedir(dirp); 00180 } 00181 00182 // return values 00183 ST_LOGPRINTF("Installed %d locales.", locale_installed_num); 00184 *locale_installed_tbl = loc_locale_installed_tbl; 00185 return locale_installed_num; 00186 }

| void free_installed_locales | ( | iLiad_locale_t ** | locale_installed_tbl, | |
| gint | locale_installed_num | |||
| ) | 
Definition at line 188 of file languages.c.
00189 { 00190 ST_LOGPRINTF("entry [%d]", locale_installed_num); 00191 gint i; 00192 iLiad_locale_t* locp; 00193 iLiad_locale_t* loc_locale_installed_tbl; 00194 00195 g_return_if_fail(locale_installed_tbl != NULL); 00196 g_return_if_fail(locale_installed_num > 0); 00197 00198 loc_locale_installed_tbl = *locale_installed_tbl; 00199 g_return_if_fail(loc_locale_installed_tbl != NULL); 00200 00201 for (i = 0; i < locale_installed_num; i++) 00202 { 00203 locp = &loc_locale_installed_tbl[i]; 00204 ST_LOGPRINTF("locp [%d] [%p]", i, locp); 00205 if (locp) 00206 { 00207 ST_LOGPRINTF("%s, %s", locp->code, locp->name); 00208 g_free( (gchar*)(locp->code ) ); // const_cast 00209 g_free( (gchar*)(locp->name ) ); // const_cast 00210 g_free( (gchar*)(locp->long_name) ); // const_cast 00211 } 00212 } 00213 00214 g_free(loc_locale_installed_tbl); 00215 *locale_installed_tbl = NULL; 00216 }
| void languagesInit | ( | ) | 
init the language/localisation settings
| none | 
Definition at line 218 of file languages.c.
00219 { 00220 char *result; 00221 char *theLanguage; 00222 00223 #if ENABLE_NLS 00224 ST_LANGUAGEPRINTF("ENABLE_NLS = TRUE"); 00225 #else 00226 ST_LANGUAGEPRINTF("ENABLE_NLS = FALSE"); 00227 #endif 00228 00229 theLanguage = iLiad_config_data_get_language(); 00230 if ( theLanguage == NULL 00231 || theLanguage[0] == '\0' ) 00232 { 00233 // default is english 00234 theLanguage = DEFAULT_LOCALE; 00235 } 00236 00237 setlocale(LC_ALL, theLanguage); 00238 g_setenv("LANG", theLanguage, 1); 00239 00240 textdomain(PACKAGE); 00241 00242 ST_LANGUAGEPRINTF("Language: [%s]", theLanguage); 00243 ST_LANGUAGEPRINTF("LOCALE_DIR: [%s]", LOCALE_DIR); 00244 ST_LANGUAGEPRINTF("PACKAGE: [%s]", PACKAGE); 00245 00246 result = bindtextdomain(PACKAGE, LOCALE_DIR);; 00247 00248 ST_LANGUAGEPRINTF("bindtextdomain: [%s]", result); 00249 00250 textdomain(PACKAGE); 00251 }

| static int locale_cmp | ( | const void * | left, | |
| const void * | right | |||
| ) |  [static] | 
Definition at line 69 of file languages.c.
00070 { 00071 const iLiad_locale_t *locp; 00072 const gchar *left_name = ((iLiad_locale_t*)left )->name; 00073 const gchar *right_name = ((iLiad_locale_t*)right)->name; 00074 00075 gint pos; 00076 gint left_pos = 9999; 00077 gint right_pos = 9999; 00078 00079 pos = 0; 00080 for (locp = g_locale_known_tbl ; locp->code ; locp++) 00081 { 00082 if (strcmp(left_name, locp->name) == 0) 00083 { 00084 left_pos = pos; 00085 } 00086 if (strcmp(right_name, locp->name) == 0) 00087 { 00088 right_pos = pos; 00089 } 00090 pos++; 00091 } 00092 00093 return left_pos - right_pos; 00094 }
| const iLiad_locale_t g_locale_known_tbl[]  [static] | 
Initial value:
 {
                                                      { "en_US",  "English"    , "Set English as the language for your iLiad"       },  
                                                      { "de_DE",  "Deutsch"    , "Ich möchte Deutsch als Sprache des iLiad"         },  
                                                      { "es_ES",  "Español"    , "Seleccionar el idioma Español para su iLiad"      },  
                                                      { "fr_FR",  "Français"   , "Employer le français comme langue de votre iLiad" },  
                                                      { "it_IT",  "Italiano"   , "Scegli italiano come lingua per il tuo iLiad"     },  
                                                      { "nl_NL",  "Nederlands" , "Kies Nederlands als taal voor uw iLiad"           },  
                                                      { "no_NO",  "Norsk"      , "Set Norwegian as the language for your iLiad"     },  
                                                      { "pl_PL",  "Polski"     , "Set Polish as the language for your iLiad"        },  
                                                      { "pt_PT",  "Português"  , "Seleccionar Português como língua do seu iLiad"   },  
                                                      { "ru_RU",  "Русский"    , "Set Russian as the language for your iLiad"       },  
                                                      { "fi_FI",  "Suomi"      , "Set Finnish as the language for your iLiad"       },  
                                                      { "sv_SE",  "Svenska"    , "Sätt svenska som språk för din iLiad"             },  
                                                      { "zh_CN",  "中文"       , "设置中文为iLiad的默认语言"                        },  
                                                      { "ja_JP",  "日本語"     , "Set Japanese as the language for your iLiad"      },  
                                                      { "ko_KR",  "한국어"     , "Set Korean as the language for your iLiad"        },  
                                                      { NULL,      NULL        , NULL                                               }
                                                    }
Definition at line 50 of file languages.c.
 1.5.6
 1.5.6