1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-04-11 15:07:07 +00:00

FS-11184 [core] retry xml_locate_language for primary language

This commit is contained in:
lazedo 2018-06-07 08:45:34 +00:00
parent 3c7db639fd
commit 9d9b44e5f6

@ -3144,7 +3144,7 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond, int *offse
return time_match;
}
SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language) {
SWITCH_DECLARE(switch_status_t) switch_xml_locate_language_ex(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language) {
switch_status_t status = SWITCH_STATUS_FALSE;
if (switch_xml_locate("languages", NULL, NULL, NULL, root, node, params, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
@ -3201,6 +3201,24 @@ done:
return status;
}
SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language) {
switch_status_t status;
if ((status = switch_xml_locate_language_ex(root, node, params, language, phrases, macros, str_language)) != SWITCH_STATUS_SUCCESS) {
const char *str_language_dup = strdup(str_language);
char *secondary;
if ((secondary=strchr(str_language_dup, '-')) != NULL) {
*secondary++ = '\0';
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "language %s not found. trying %s by removing %s\n", str_language, str_language_dup, secondary);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "lang", str_language_dup);
status = switch_xml_locate_language_ex(root, node, params, language, phrases, macros, str_language_dup);
}
switch_safe_free(str_language_dup);
}
return status;
}
#ifdef WIN32
/*
* globbing functions for windows, part of libc on unix, this code was cut and paste from