2007-11-04 01:32:35 -08:00
|
|
|
#include "Efreet.h"
|
2007-02-03 05:05:30 -08:00
|
|
|
#include "efreet_private.h"
|
2007-11-04 01:32:35 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2007-02-03 05:05:30 -08:00
|
|
|
|
|
|
|
int
|
|
|
|
ef_cb_locale(void)
|
|
|
|
{
|
|
|
|
int ret = 1, i;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *lc_message;
|
|
|
|
char *lang;
|
|
|
|
char *country;
|
|
|
|
char *modifier;
|
|
|
|
} langs[] = {
|
2007-09-06 09:15:10 -07:00
|
|
|
/* these are ordered such that when we move from LANG to LC_MESSAGES
|
2007-02-03 05:05:30 -08:00
|
|
|
* the LANG env will still be effect. Same with moving from
|
|
|
|
* LC_MESSAGES to LANG */
|
|
|
|
{"LANG=", NULL, NULL, NULL},
|
|
|
|
{"LANG=en", "en", NULL, NULL},
|
|
|
|
{"LANG=en@Latn", "en", NULL, "Latn"},
|
|
|
|
{"LANG=en_US", "en", "US", NULL},
|
|
|
|
{"LANG=en_US@Latn", "en", "US", "Latn"},
|
|
|
|
{"LANG=en_US.blah@Latn", "en", "US", "Latn"},
|
|
|
|
{"LC_MESSAGES=", "en", "US", "Latn"}, /* This will fallback to LANG */
|
|
|
|
{"LC_MESSAGES=fr", "fr", NULL, NULL},
|
|
|
|
{"LC_MESSAGES=fr@Blah", "fr", NULL, "Blah"},
|
|
|
|
{"LC_MESSAGES=fr_FR", "fr", "FR", NULL},
|
|
|
|
{"LC_MESSAGES=fr_FR@Blah", "fr", "FR", "Blah"},
|
|
|
|
{"LC_MESSAGES=fr_FR.Foo@Blah", "fr", "FR", "Blah"},
|
|
|
|
{"LC_ALL=", "fr", "FR", "Blah"}, /* this will fallback to LC_MESSAGES */
|
|
|
|
{"LC_ALL=sr", "sr", NULL, NULL},
|
|
|
|
{"LC_ALL=sr@Ret", "sr", NULL, "Ret"},
|
|
|
|
{"LC_ALL=sr_YU", "sr", "YU", NULL},
|
|
|
|
{"LC_ALL=sr_YU@Ret", "sr", "YU", "Ret"},
|
|
|
|
{"LC_ALL=sr_YU.ssh@Ret", "sr", "YU", "Ret"},
|
|
|
|
{NULL, NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* reset everything to blank */
|
|
|
|
putenv("LC_ALL=");
|
|
|
|
putenv("LC_MESSAGES=");
|
|
|
|
putenv("LANG=");
|
|
|
|
|
2010-08-21 06:52:25 -07:00
|
|
|
for (i = 0; langs[i].lc_message; i++)
|
2007-02-03 05:05:30 -08:00
|
|
|
{
|
|
|
|
const char *tmp;
|
|
|
|
|
|
|
|
putenv(langs[i].lc_message);
|
|
|
|
|
|
|
|
tmp = efreet_lang_get();
|
|
|
|
if ((langs[i].lang && (!tmp || strcmp(tmp, langs[i].lang)))
|
|
|
|
|| (!langs[i].lang && tmp))
|
|
|
|
{
|
2007-09-06 09:15:10 -07:00
|
|
|
printf("efreet_lang_get() is wrong (%s) with %s\n",
|
2007-02-03 05:05:30 -08:00
|
|
|
tmp, langs[i].lang);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = efreet_lang_country_get();
|
|
|
|
if ((langs[i].country && (!tmp || strcmp(tmp, langs[i].country)))
|
|
|
|
|| (!langs[i].country && tmp))
|
|
|
|
{
|
2007-09-06 09:15:10 -07:00
|
|
|
printf("efreet_lang_country_get() is wrong (%s) with %s\n",
|
2007-02-03 05:05:30 -08:00
|
|
|
tmp, langs[i].lang);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = efreet_lang_modifier_get();
|
2007-09-06 09:15:10 -07:00
|
|
|
if ((langs[i].modifier && (!tmp || strcmp(tmp, langs[i].modifier)))
|
2007-02-03 05:05:30 -08:00
|
|
|
|| (!langs[i].modifier && tmp))
|
|
|
|
{
|
|
|
|
printf("efreet_lang_modifier_get() is wrong with %s with %s\n",
|
|
|
|
tmp, langs[i].lang);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
efreet_shutdown();
|
|
|
|
efreet_init();
|
|
|
|
}
|
2007-09-06 09:15:10 -07:00
|
|
|
|
2007-02-03 05:05:30 -08:00
|
|
|
return ret;
|
|
|
|
}
|