#include "config.h"
#include <locale.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <liberregxml/erregapi.h>
#include "contentListerLog.h"
#include "gettext.h"
#include "languages.h"
Go to the source code of this file.
Functions | |
gboolean | languageSelected (void) |
void | languagesInit () |
const gchar * | languagesGetLocale () |
const gchar * | languagesGetCountry () |
const gchar * | languagesGetDefaultCountry () |
Variables | |
static gchar * | g_szUserLanguage = NULL |
<File description>="">
Definition in file languages.c.
gboolean languageSelected | ( | void | ) |
Definition at line 56 of file languages.c.
00057 { 00058 gboolean ret = FALSE; // return value 00059 struct stat statbuf; 00060 char* cp; 00061 00062 CL_LOGPRINTF("entry"); 00063 00064 cp = g_strdup_printf(LOCALE_LIB_DIR "/%s", g_szUserLanguage); 00065 if ( stat(cp, &statbuf) == 0 00066 && S_ISDIR(statbuf.st_mode) ) 00067 { 00068 ret = TRUE; 00069 } 00070 g_free(cp); 00071 00072 return ret; 00073 }
const gchar* languagesGetCountry | ( | void | ) |
return the current country setting
none |
Definition at line 123 of file languages.c.
00124 { 00125 static gchar *country = NULL; 00126 char *cp; 00127 00128 g_free(country); 00129 country = g_strdup(g_szUserLanguage); 00130 00131 cp = strchr(country, '_'); 00132 if (cp != NULL) 00133 { 00134 *cp = '\0'; 00135 } 00136 00137 return country; 00138 }
const gchar* languagesGetDefaultCountry | ( | void | ) |
return the default country
none |
Definition at line 140 of file languages.c.
00141 { 00142 static gchar *country = NULL; 00143 char *cp; 00144 00145 g_free(country); 00146 country = g_strdup(DEFAULT_LOCALE); 00147 00148 cp = strchr(country, '_'); 00149 if (cp != NULL) 00150 { 00151 *cp = '\0'; 00152 } 00153 00154 return country; 00155 }
const gchar* languagesGetLocale | ( | void | ) |
return the current locale setting
none |
Definition at line 118 of file languages.c.
00119 { 00120 return g_szUserLanguage ? g_szUserLanguage : DEFAULT_LOCALE; 00121 }
void languagesInit | ( | void | ) |
init the language/localisation settings
none |
Definition at line 75 of file languages.c.
00076 { 00077 char *result; 00078 regUserSetting_t *theUserSetting = NULL; 00079 00080 #if ENABLE_NLS 00081 CL_LOGPRINTF("ENABLE_NLS = TRUE"); 00082 #else 00083 CL_LOGPRINTF("ENABLE_NLS = FALSE"); 00084 #endif 00085 00086 // retrieve user setting from registry 00087 g_free(g_szUserLanguage); 00088 theUserSetting = erRegGetUserSetting(); 00089 if (theUserSetting) 00090 { 00091 CL_LOGPRINTF("Using LOCALE: %s\n", theUserSetting->language); 00092 setlocale(LC_ALL, theUserSetting->language); 00093 g_setenv("LANG", theUserSetting->language, 1); 00094 g_szUserLanguage = g_strdup(theUserSetting->language); 00095 erRegFreeUserSetting(theUserSetting); 00096 } 00097 else 00098 { 00099 // default is english 00100 CL_WARNPRINTF("Using default LOCALE: %s\n", DEFAULT_LOCALE); 00101 setlocale(LC_ALL, DEFAULT_LOCALE); 00102 g_setenv("LANG", DEFAULT_LOCALE, 1); 00103 g_szUserLanguage = g_strdup(DEFAULT_LOCALE); 00104 } 00105 00106 textdomain(PACKAGE); 00107 00108 CL_LOGPRINTF("LOCALE_DIR: %s", LOCALE_DIR); 00109 CL_LOGPRINTF("PACKAGE: %s", PACKAGE); 00110 00111 result = bindtextdomain(PACKAGE, LOCALE_DIR);; 00112 00113 CL_LOGPRINTF("bindtextdomain: %s", result); 00114 00115 textdomain(PACKAGE); 00116 }
gchar* g_szUserLanguage = NULL [static] |
Definition at line 49 of file languages.c.