void find_localized_paths (void) { int messages_done = 0; int help_done = 0; const char* intl_suffix = ""; char intl_lang[128]; /* First, try the locale "as is" */ #if defined (ENABLE_NLS) && defined (HAVE_LC_MESSAGES) intl_suffix = guess_category_value(LC_MESSAGES,"LC_MESSAGES"); #else intl_suffix = guess_category_value(0,"LC_MESSAGES"); #endif debug_printf ("GUESS 1 -- intl_suffix is %s\n", intl_suffix); if (strcmp(intl_suffix,"C") && strcmp(intl_suffix,"")) { sprintf (message_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "messages", PATH_SLASH, intl_suffix, PATH_SLASH); debug_printf ("Trying Message Path %s\n", message_path); if (directory_exists(message_path)) { debug_printf ("Set Message Path %s\n", message_path); messages_done = 1; } sprintf (help_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "help", PATH_SLASH, intl_suffix, PATH_SLASH); debug_printf ("Trying Help Path %s\n", help_path); if (directory_exists(help_path)) { debug_printf ("Set Help Path %s\n", help_path); help_done = 1; } } if (messages_done && help_done) return; /* Next, try stripping off the country suffix */ strncpy (intl_lang, intl_suffix, 128); intl_lang[127] = '\0'; lincity_nl_find_language (intl_lang); intl_suffix = intl_lang; debug_printf ("GUESS 2 -- intl_suffix is %s\n", intl_suffix); if (strcmp(intl_suffix,"C") && strcmp(intl_suffix,"")) { if (!messages_done) { sprintf (message_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "messages", PATH_SLASH, intl_suffix, PATH_SLASH); debug_printf ("Trying Message Path %s\n", message_path); if (directory_exists(message_path)) { debug_printf ("Set Message Path %s\n", message_path); messages_done = 1; } } if (!help_done) { sprintf (help_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "help", PATH_SLASH, intl_suffix, PATH_SLASH); debug_printf ("Trying Help Path %s\n", help_path); if (directory_exists(help_path)) { debug_printf ("Set Help Path %s\n", help_path); help_done = 1; } } } if (messages_done && help_done) return; /* Finally, settle for default English messages */ if (!messages_done) { sprintf (message_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "messages", PATH_SLASH); debug_printf ("Settling for message Path %s\n", message_path); } if (!help_done) { sprintf (help_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "help", PATH_SLASH); debug_printf ("Settling for help Path %s\n", help_path); } }
void init_path_strings (void) { char* homedir = NULL; const char* intl_suffix = ""; #if defined (WIN32) find_libdir (); homedir = LIBDIR; #elif defined (__EMX__) strcpy(LIBDIR, __XOS2RedirRoot(OS2_DEFAULT_LIBDIR)); #else homedir = getenv ("HOME"); #endif #if defined (ENABLE_NLS) #if defined (HAVE_LC_MESSAGES) intl_suffix = guess_category_value(LC_MESSAGES,"LC_MESSAGES"); #else intl_suffix = guess_category_value(0,"LC_MESSAGES"); #endif #endif printf ("intl_suffix is %s\n", intl_suffix); lc_save_dir_len = strlen (homedir) + strlen (LC_SAVE_DIR) + 1; if ((lc_save_dir = (char *) malloc (lc_save_dir_len + 1)) == 0) malloc_failure (); sprintf (lc_save_dir, "%s%c%s", homedir, PATH_SLASH, LC_SAVE_DIR); sprintf (colour_pal_file, "%s%c%s", LIBDIR, PATH_SLASH, "colour.pal"); sprintf (opening_path, "%s%c%s", LIBDIR, PATH_SLASH, "opening"); #if defined (WIN32) sprintf (opening_pic, "%s%c%s",opening_path,PATH_SLASH,"open.tga"); #else sprintf (opening_pic, "%s%c%s",opening_path,PATH_SLASH,"open.tga.gz"); #endif sprintf (graphic_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "icons", PATH_SLASH); if (strcmp(intl_suffix,"C") && strcmp(intl_suffix,"")) { sprintf (message_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "messages", PATH_SLASH, intl_suffix, PATH_SLASH); sprintf (help_path, "%s%c%s%c%s%c", LIBDIR, PATH_SLASH, "help", PATH_SLASH, intl_suffix, PATH_SLASH); printf ("Trying Message Path %s\n", message_path); if (!directory_exists(message_path)) { sprintf (message_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "messages", PATH_SLASH); printf ("Settling for message Path %s\n", message_path); } if (!directory_exists(help_path)) { sprintf (help_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "help", PATH_SLASH); } } else { sprintf (message_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "messages", PATH_SLASH); sprintf (help_path, "%s%c%s%c", LIBDIR, PATH_SLASH, "help", PATH_SLASH); printf ("Default message path %s\n", message_path); } sprintf (fontfile, "%s%c%s", opening_path, PATH_SLASH, "iso8859-1-8x8.raw"); #if defined (WIN32) /* GCS: Use windows font for extra speed */ strcpy (windowsfontfile, LIBDIR); if (!pix_double) strcat (windowsfontfile, "\\opening\\iso8859-1-8x8.fnt"); else strcat (windowsfontfile, "\\opening\\iso8859-1-9x15.fnt"); #endif lc_temp_filename = (char *) malloc (lc_save_dir_len + 16); if (lc_temp_filename == 0) { malloc_failure (); } sprintf (lc_temp_filename, "%s%c%s", lc_save_dir, PATH_SLASH, "tmp-file"); }
/** * g_i18n_get_language_list: * @category_name: Name of category to look up, e.g. "LC_MESSAGES". * * This computes a list of language strings. It searches in the * standard environment variables to find the list, which is sorted * in order from most desirable to least desirable. The `C' locale * is appended to the list if it does not already appear (other routines depend on this behaviour). * If @category_name is %NULL, then LC_ALL is assumed. * * Return value: the list of languages, this list should not be freed as it is owned by gnome-i18n **/ const GList * g_i18n_get_language_list (const gchar *category_name) { GList *list; if (!category_name) category_name= "LC_ALL"; if (category_table) { #if 0 // we want a fresh reading of the LANG variable every time so we can // work out the 8bit encoding under utf-8 locale list= (GList *)g_hash_table_lookup (category_table, (const gpointer) category_name); #else xxx_UT_DEBUGMSG(("recreating hash table\n")); g_hash_table_destroy (category_table); category_table= g_hash_table_new (g_str_hash, g_str_equal); list= NULL; #endif } else { category_table= g_hash_table_new (g_str_hash, g_str_equal); list= NULL; } if (!list) { gint c_locale_defined= FALSE; const gchar *category_value; gchar *category_memory, *orig_category_memory; category_value = guess_category_value (category_name); if (! category_value) category_value = "C"; orig_category_memory = category_memory = (gchar*) g_malloc (strlen (category_value)+1); while (category_value[0] != '\0') { while (category_value[0] != '\0' && category_value[0] == ':') ++category_value; if (category_value[0] != '\0') { char *cp= category_memory; while (category_value[0] != '\0' && category_value[0] != ':') *category_memory++= *category_value++; category_memory[0]= '\0'; category_memory++; cp = unalias_lang(cp); if (strcmp (cp, "C") == 0) c_locale_defined= TRUE; list= g_list_concat (list, compute_locale_variants (cp)); } } g_free (orig_category_memory); if (!c_locale_defined) list= g_list_append (list, (void*)"C"); g_hash_table_insert (category_table, (gpointer) category_name, list); } return list; }