contentLister/inc/languages.h File Reference

contentLister application - internationalization More...

#include "config.h"
#include "gettext.h"

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

Go to the source code of this file.

Defines

#define _(String)   gettext (String)
#define DEFAULT_LOCALE   "en_US"
#define LOCALE_LIB_DIR   "/usr/lib/locale"

Functions

gboolean languageSelected (void)
void languagesInit (void)
const gchar * languagesGetLocale (void)
const gchar * languagesGetCountry (void)
const gchar * languagesGetDefaultCountry (void)


Detailed Description

contentLister application - internationalization

<File description>="">

Definition in file languages.h.


Define Documentation

#define _ ( String   )     gettext (String)

Definition at line 41 of file languages.h.

#define DEFAULT_LOCALE   "en_US"

Definition at line 43 of file languages.h.

#define LOCALE_LIB_DIR   "/usr/lib/locale"

Definition at line 44 of file languages.h.


Function Documentation

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

Parameters:
none 
Returns:
character pointer to the country code (e.g. "en")

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

Parameters:
none 
Returns:
character pointer to the country code (e.g. "en")

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

Parameters:
none 
Returns:
character pointer to the locale code (e.g. "en_US"

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

Parameters:
none 
Returns:
void

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 }

Here is the call graph for this function:


Generated on Sun Dec 14 17:12:56 2008 by  doxygen 1.5.6