summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-05-30 13:16:29 +0000
committerMark Spencer <markster@digium.com>2005-05-30 13:16:29 +0000
commitf4d629f4ca17bb5a5cf221205dd9ab14bf9b3efe (patch)
treeff694179b665a7c51fc749bf6f87f9e978472577 /file.c
parent4e329973eb9c5242ee6f4ecb7f148c63ae11a16b (diff)
Fix language handling (bug #4399)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5783 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'file.c')
-rwxr-xr-xfile.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/file.c b/file.c
index 876177a94..f4dbe6268 100755
--- a/file.c
+++ b/file.c
@@ -729,23 +729,31 @@ int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
*c = '\0';
postfix = c+1;
prefix = tmp;
+ snprintf(filename2, sizeof(filename2), "%s/%s/%s", prefix, preflang, postfix);
} else {
postfix = tmp;
prefix="";
+ snprintf(filename2, sizeof(filename2), "%s/%s", preflang, postfix);
}
- snprintf(filename2, sizeof(filename2), "%s/%s/%s", prefix, preflang, postfix);
res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS);
if (res < 1) {
char *stringp=NULL;
strncpy(lang2, preflang, sizeof(lang2)-1);
stringp=lang2;
strsep(&stringp, "_");
+ /* If language is a specific locality of a language (like es_MX), strip the locality and try again */
if (strcmp(lang2, preflang)) {
- snprintf(filename2, sizeof(filename2), "%s/%s/%s", prefix, lang2, postfix);
+ if (ast_strlen_zero(prefix)) {
+ snprintf(filename2, sizeof(filename2), "%s/%s", lang2, postfix);
+ } else {
+ snprintf(filename2, sizeof(filename2), "%s/%s/%s", prefix, lang2, postfix);
+ }
res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS);
}
}
}
+
+ /* Fallback to no language (usually winds up being American English) */
if (res < 1) {
res = ast_filehelper(filename, NULL, fmt, ACTION_EXISTS);
}