Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/help.c @ 1650:cd81806b5947
Try fallback language (en) when help file with current language is not found
Patch by Nixtrian, slightly modified by Mikael
author | Nixtrian |
---|---|
date | Tue, 17 Nov 2009 23:09:06 +0100 |
parents | dcd5d4c75199 |
children |
comparison
equal
deleted
inserted
replaced
1649:44bbdc961234 | 1650:cd81806b5947 |
---|---|
76 } | 76 } |
77 | 77 |
78 // Look for help file | 78 // Look for help file |
79 lang = get_lang(); | 79 lang = get_lang(); |
80 helpfiles_dir = g_strdup_printf("%s/mcabber/help", DATA_DIR); | 80 helpfiles_dir = g_strdup_printf("%s/mcabber/help", DATA_DIR); |
81 p = NULL; | |
82 | |
81 if (string && *string) { | 83 if (string && *string) { |
82 p = g_strdup(string); | 84 p = g_strdup(string); |
83 mc_strtolower(p); | 85 mc_strtolower(p); |
84 filename = g_strdup_printf("%s/%s/hlp_%s.txt", helpfiles_dir, lang, p); | 86 filename = g_strdup_printf("%s/%s/hlp_%s.txt", helpfiles_dir, lang, p); |
85 g_free(p); | |
86 } else | 87 } else |
87 filename = g_strdup_printf("%s/%s/hlp.txt", helpfiles_dir, lang); | 88 filename = g_strdup_printf("%s/%s/hlp.txt", helpfiles_dir, lang); |
88 | 89 |
89 fp = fopen(filename, "r"); | 90 fp = fopen(filename, "r"); |
91 | |
92 if (!(fp) && (g_strcmp0(lang, DEFAULT_LANG)) ) { | |
93 g_free(filename); | |
94 if (p) | |
95 filename = g_strdup_printf("%s/%s/hlp_%s.txt", helpfiles_dir, DEFAULT_LANG, p); | |
96 else | |
97 filename = g_strdup_printf("%s/%s/hlp.txt", helpfiles_dir, DEFAULT_LANG); | |
98 | |
99 fp = fopen(filename, "r"); | |
100 } | |
101 g_free(p); | |
90 g_free(filename); | 102 g_free(filename); |
91 g_free(helpfiles_dir); | 103 g_free(helpfiles_dir); |
92 | 104 |
93 if (!fp) { | 105 if (!fp) { |
94 scr_LogPrint(LPRINT_NORMAL, "No help found."); | 106 scr_LogPrint(LPRINT_NORMAL, "No help found."); |