コード例 #1
0
ファイル: i18n_findlocale.c プロジェクト: Classixz/etlegacy
static const int lcid_to_fl(LCID lcid, FL_Locale *rtn)
{
	LANGID langid       = LANGIDFROMLCID(lcid);
	LANGID primary_lang = PRIMARYLANGID(langid);
	LANGID sub_lang     = SUBLANGID(langid);
	int    i;

	// try to find an exact primary/sublanguage combo that we know about
	for (i = 0; i < num_both_to_code; ++i)
	{
		if (both_to_code[i].id == langid)
		{
			accumulate_locstring(both_to_code[i].code, rtn);
			return 1;
		}
	}
	// fallback to just checking the primary language id
	for (i = 0; i < num_primary_to_code; ++i)
	{
		if (primary_to_code[i].id == primary_lang)
		{
			accumulate_locstring(primary_to_code[i].code, rtn);
			return 1;
		}
	}
	return 0;
}
コード例 #2
0
ファイル: llfindlocale.cpp プロジェクト: AlchemyDev/Carbon
FL_Success
FL_FindLocale(FL_Locale **locale, FL_Domain domain) {
  FL_Success success = FL_FAILED;
  FL_Locale *rtn = (FL_Locale*)malloc(sizeof(FL_Locale));
  rtn->lang = NULL;
  rtn->country = NULL;
  rtn->variant = NULL;

#ifdef WIN32
  /* win32 >= mswindows95 */
  {
    LCID lcid = GetThreadLocale();
    if (lcid_to_fl(lcid, rtn)) {
      success = FL_CONFIDENT;
    }
    if (success == FL_FAILED) {
      /* assume US English on mswindows systems unless we know otherwise */
      if (accumulate_locstring("en_US.ISO_8859-1", rtn)) {
        success = FL_DEFAULT_GUESS;
      }
    }
  }
#else
  /* assume unixoid */
  {
    /* examples: */
    /* sv_SE.ISO_8859-1 */
    /* fr_FR.ISO8859-1 */
    /* no_NO_NB */
    /* no_NO_NY */
    /* no_NO */
    /* de_DE */
    /* try the various vars in decreasing order of authority */
    if (accumulate_env("LC_ALL", rtn) ||
        accumulate_env("LC_MESSAGES", rtn) ||
        accumulate_env("LANG", rtn) ||
        accumulate_env("LANGUAGE", rtn)) {
      success = FL_CONFIDENT;
    }
    if (success == FL_FAILED) {
      /* assume US English on unixoid systems unless we know otherwise */
      if (accumulate_locstring("en_US.ISO_8859-1", rtn)) {
        success = FL_DEFAULT_GUESS;
      }
    }
  }
#endif

  if (success != FL_FAILED) {
    canonise_fl(rtn);
  }

  *locale = rtn;
  return success;
}
コード例 #3
0
ファイル: llfindlocale.cpp プロジェクト: AlchemyDev/Carbon
static int
accumulate_env(const char *name, FL_Locale *l) {
  char *env = getenv(name);
  if (env) {
    return accumulate_locstring(env, l);
  }
  return 0;
}
コード例 #4
0
static int
accumulate_env(const char *name, FL_Locale *l) {
  char *env;
  char *lang = NULL;
  char *country = NULL;
  char *variant = NULL;
  env = getenv(name);
  if (env) {
    return accumulate_locstring(env, l);
  }
  free(lang); free(country); free(variant);
  return 0;
}